Class: Granite::Action::Projectors::ProjectorsCollection
- Inherits:
-
Object
- Object
- Granite::Action::Projectors::ProjectorsCollection
- Defined in:
- lib/granite/action/projectors.rb
Instance Method Summary collapse
- #fetch(name) ⇒ Object
-
#initialize(action_class) ⇒ ProjectorsCollection
constructor
A new instance of ProjectorsCollection.
- #names ⇒ Object
- #store(name, options, &block) ⇒ Object
Constructor Details
#initialize(action_class) ⇒ ProjectorsCollection
Returns a new instance of ProjectorsCollection.
7 8 9 10 11 |
# File 'lib/granite/action/projectors.rb', line 7 def initialize(action_class) @action_class = action_class @storage = {} @cache = {} end |
Instance Method Details
#fetch(name) ⇒ Object
13 14 15 |
# File 'lib/granite/action/projectors.rb', line 13 def fetch(name) @cache[name.to_sym] ||= setup_projector(name) end |
#names ⇒ Object
25 26 27 |
# File 'lib/granite/action/projectors.rb', line 25 def names @storage.keys | (@action_class.superclass < Granite::Action ? @action_class.superclass._projectors.names : []) end |
#store(name, options, &block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/granite/action/projectors.rb', line 17 def store(name, , &block) , old_blocks = (name) @storage[name.to_sym] = [ .merge( || {}), old_blocks + [block].compact ] end |