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

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#_projectorsObject



74
75
76
# File 'lib/granite/action/projectors.rb', line 74

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

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



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

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



78
79
80
# File 'lib/granite/action/projectors.rb', line 78

def projector_names
  _projectors.names
end