Class: Aldous::Controller::Action::Precondition

Inherits:
Object
  • Object
show all
Includes:
Aldous
Defined in:
lib/aldous/controller/action/precondition.rb,
lib/aldous/controller/action/precondition/wrapper.rb

Defined Under Namespace

Classes: Wrapper

Constant Summary

Constants included from Aldous

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Aldous

configuration

Constructor Details

#initialize(action) ⇒ Precondition

Returns a new instance of Precondition.



32
33
34
# File 'lib/aldous/controller/action/precondition.rb', line 32

def initialize(action)
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



30
31
32
# File 'lib/aldous/controller/action/precondition.rb', line 30

def action
  @action
end

Class Method Details

.build(action) ⇒ Object



11
12
13
# File 'lib/aldous/controller/action/precondition.rb', line 11

def build(action)
  Aldous::Controller::Action::Precondition::Wrapper.new(new(action))
end

.inherited(klass) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/aldous/controller/action/precondition.rb', line 19

def inherited(klass)
  ::Aldous.configuration.controller_methods_exposed_to_action.each do |method_name|
    unless klass.method_defined?(method_name)
      define_method method_name do
        action.controller.send(method_name)
      end
    end
  end
end

.perform(action) ⇒ Object



15
16
17
# File 'lib/aldous/controller/action/precondition.rb', line 15

def perform(action)
  build(action).perform
end

Instance Method Details

#build_view(respondable_class, extra_data = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/aldous/controller/action/precondition.rb', line 40

def build_view(respondable_class, extra_data = {})
  ::Aldous::BuildRespondableService.new(
    view_context: action.controller.view_context,
    default_view_data: action.default_view_data,
    respondable_class: respondable_class,
    status: extra_data[:status],
    extra_data: extra_data
  ).perform
end

#performObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/aldous/controller/action/precondition.rb', line 36

def perform
  raise NotImplementedError.new("#{self.class.name} must implement method #perform")
end