Class: SimpleEnum::Multiple::CollectionProxy
- Inherits:
-
Object
- Object
- SimpleEnum::Multiple::CollectionProxy
- Includes:
- Enumerable
- Defined in:
- lib/simple_enum/multiple/collection_proxy.rb
Instance Attribute Summary collapse
-
#accessor ⇒ Object
readonly
Returns the value of attribute accessor.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
Instance Method Summary collapse
- #delete(key) ⇒ Object
-
#initialize(origin, accessor) ⇒ CollectionProxy
constructor
A new instance of CollectionProxy.
- #proxy ⇒ Object (also: #to_a)
- #push(*keys) ⇒ Object (also: #<<)
Constructor Details
#initialize(origin, accessor) ⇒ CollectionProxy
Returns a new instance of CollectionProxy.
8 9 10 |
# File 'lib/simple_enum/multiple/collection_proxy.rb', line 8 def initialize(origin, accessor) @origin, @accessor = origin, accessor end |
Instance Attribute Details
#accessor ⇒ Object (readonly)
Returns the value of attribute accessor.
6 7 8 |
# File 'lib/simple_enum/multiple/collection_proxy.rb', line 6 def accessor @accessor end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
6 7 8 |
# File 'lib/simple_enum/multiple/collection_proxy.rb', line 6 def origin @origin end |
Instance Method Details
#delete(key) ⇒ Object
19 20 21 |
# File 'lib/simple_enum/multiple/collection_proxy.rb', line 19 def delete(key) origin.delete(accessor.enum.value(key)) && key end |
#proxy ⇒ Object Also known as: to_a
23 24 25 |
# File 'lib/simple_enum/multiple/collection_proxy.rb', line 23 def proxy accessor.fetch_keys(origin) end |
#push(*keys) ⇒ Object Also known as: <<
12 13 14 15 16 |
# File 'lib/simple_enum/multiple/collection_proxy.rb', line 12 def push(*keys) keys = accessor.filter_keys(keys) origin.push(*accessor.fetch_values(keys)).uniq! self end |