Class: Grape::Util::LazyValue
- Inherits:
-
Object
- Object
- Grape::Util::LazyValue
- Defined in:
- lib/grape/util/lazy_value.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#access_keys ⇒ Object
readonly
Returns the value of attribute access_keys.
Instance Method Summary collapse
- #evaluate ⇒ Object
- #evaluate_from(configuration) ⇒ Object
-
#initialize(value, access_keys = []) ⇒ LazyValue
constructor
A new instance of LazyValue.
- #lazy? ⇒ Boolean
- #reached_by(parent_access_keys, access_key) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value, access_keys = []) ⇒ LazyValue
Returns a new instance of LazyValue.
8 9 10 11 |
# File 'lib/grape/util/lazy_value.rb', line 8 def initialize(value, access_keys = []) @value = value @access_keys = access_keys end |
Instance Attribute Details
#access_keys ⇒ Object (readonly)
Returns the value of attribute access_keys.
6 7 8 |
# File 'lib/grape/util/lazy_value.rb', line 6 def access_keys @access_keys end |
Instance Method Details
#evaluate ⇒ Object
18 19 20 |
# File 'lib/grape/util/lazy_value.rb', line 18 def evaluate @value end |
#evaluate_from(configuration) ⇒ Object
13 14 15 16 |
# File 'lib/grape/util/lazy_value.rb', line 13 def evaluate_from(configuration) matching_lazy_value = configuration.fetch(@access_keys) matching_lazy_value.evaluate end |
#lazy? ⇒ Boolean
22 23 24 |
# File 'lib/grape/util/lazy_value.rb', line 22 def lazy? true end |
#reached_by(parent_access_keys, access_key) ⇒ Object
26 27 28 29 |
# File 'lib/grape/util/lazy_value.rb', line 26 def reached_by(parent_access_keys, access_key) @access_keys = parent_access_keys + [access_key] self end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/grape/util/lazy_value.rb', line 31 def to_s evaluate.to_s end |