Module: Granite::Action::Projectors::ClassMethods

Defined in:
lib/granite/action/projectors.rb

Instance Method Summary collapse

Instance Method Details

#_projectorsObject



76
77
78
# File 'lib/granite/action/projectors.rb', line 76

def _projectors
  @_projectors ||= ProjectorsCollection.new(self)
end

#projector(name, options = {}, &block) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/granite/action/projectors.rb', line 84

def projector(name, options = {}, &block)
  _projectors.store(name, options, &block)

  class_eval <<-METHOD, __FILE__, __LINE__ + 1
    def self.#{name}                                                # def self.foo
      _projectors.fetch(:#{name})                                   #   _projectors.fetch(:foo)
    end                                                             # end
                                                                    #
    def #{name}                                                     # def foo
      @#{name} ||= self.class._projectors.fetch(:#{name}).new(self) #   @foo ||= self.class._projectors.fetch(:foo).new(self)
    end                                                             # end
  METHOD
end

#projector_namesObject



80
81
82
# File 'lib/granite/action/projectors.rb', line 80

def projector_names
  _projectors.names
end