Class: Encase::ContainerItem
- Inherits:
-
Object
- Object
- Encase::ContainerItem
- Defined in:
- lib/encase/container_item.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#key ⇒ Object
Returns the value of attribute key.
-
#reified_value ⇒ Object
Returns the value of attribute reified_value.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#fetch ⇒ Object
returns just the reified value by default.
-
#initialize(container) ⇒ ContainerItem
constructor
A new instance of ContainerItem.
- #inject(object) ⇒ Object
-
#instance ⇒ Object
public api.
- #reified? ⇒ Boolean
- #reify ⇒ Object
- #store(key, value) ⇒ Object
Constructor Details
#initialize(container) ⇒ ContainerItem
Returns a new instance of ContainerItem.
8 9 10 |
# File 'lib/encase/container_item.rb', line 8 def initialize(container) self.container = container end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
3 4 5 |
# File 'lib/encase/container_item.rb', line 3 def container @container end |
#key ⇒ Object
Returns the value of attribute key.
4 5 6 |
# File 'lib/encase/container_item.rb', line 4 def key @key end |
#reified_value ⇒ Object
Returns the value of attribute reified_value.
6 7 8 |
# File 'lib/encase/container_item.rb', line 6 def reified_value @reified_value end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/encase/container_item.rb', line 5 def value @value end |
Instance Method Details
#fetch ⇒ Object
returns just the reified value by default
42 43 44 |
# File 'lib/encase/container_item.rb', line 42 def fetch reified_value end |
#inject(object) ⇒ Object
17 18 19 |
# File 'lib/encase/container_item.rb', line 17 def inject(object) self.container.inject(object) end |
#instance ⇒ Object
public api
47 48 49 50 51 52 53 |
# File 'lib/encase/container_item.rb', line 47 def instance reify unless reified? object = fetch inject(object) object end |
#reified? ⇒ Boolean
37 38 39 |
# File 'lib/encase/container_item.rb', line 37 def reified? !self.reified_value.nil? end |
#reify ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/encase/container_item.rb', line 21 def reify return false if reified? if value.is_a? Proc if value.arity == 1 self.reified_value = value.call(container) else self.reified_value = value.call end else self.reified_value = value end true end |
#store(key, value) ⇒ Object
12 13 14 15 |
# File 'lib/encase/container_item.rb', line 12 def store(key, value) self.key = key self.value = value end |