Class: RDBr::Query::ValueLimiter
- Inherits:
-
Object
- Object
- RDBr::Query::ValueLimiter
- Defined in:
- lib/rdbr/query/value_limiter.rb
Constant Summary collapse
- SUFFIX =
'... [value truncated]'.freeze
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(max_bytes:) ⇒ ValueLimiter
constructor
A new instance of ValueLimiter.
Constructor Details
#initialize(max_bytes:) ⇒ ValueLimiter
Returns a new instance of ValueLimiter.
6 7 8 |
# File 'lib/rdbr/query/value_limiter.rb', line 6 def initialize(max_bytes:) @max_bytes = positive_integer(max_bytes) end |
Instance Method Details
#call(value) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/rdbr/query/value_limiter.rb', line 10 def call(value) case value when String then truncate(value) when Array then value.map{|item| call(item) } when Hash then value.to_h{|key, item| [ key, call(item) ] } else value end end |