Class: Granite::Projector

Inherits:
Object
  • Object
show all
Includes:
ContextProxy, ControllerActions, Helpers, Translations
Defined in:
lib/granite/projector.rb,
lib/granite/projector/error.rb,
lib/granite/projector/helpers.rb,
lib/granite/projector/translations.rb,
lib/granite/projector/controller_actions.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ControllerActions, Helpers, Translations Classes: ActionNotMountedError, Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Translations

#i18n_scopes, #translate

Methods included from Helpers

#action_path, #action_url, #view_context

Constructor Details

#initialize(*args) ⇒ Projector

Returns a new instance of Projector.



38
39
40
41
42
43
44
# File 'lib/granite/projector.rb', line 38

def initialize(*args)
  @action = if args.first.is_a?(Granite::Action) # Temporary solutions for backwards compatibility.
              args.first
            else
              build_action(*args)
            end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



16
17
18
# File 'lib/granite/projector.rb', line 16

def action
  @action
end

Class Method Details

.action_nameObject



34
35
36
# File 'lib/granite/projector.rb', line 34

def self.action_name
  @action_name ||= action_class.name.underscore
end

.controller_classObject



18
19
20
21
22
23
24
# File 'lib/granite/projector.rb', line 18

def self.controller_class
  return Granite::Controller unless superclass.respond_to?(:controller_class)

  @controller_class ||= Class.new(superclass.controller_class).tap do |klass|
    klass.projector_class = self
  end
end

.projector_nameObject



30
31
32
# File 'lib/granite/projector.rb', line 30

def self.projector_name
  @projector_name ||= name.demodulize.remove(/Projector$/).underscore
end

.projector_pathObject



26
27
28
# File 'lib/granite/projector.rb', line 26

def self.projector_path
  @projector_path ||= name.remove(/Projector$/).underscore
end