Module: Trailblazer::V1_1::Operation::Model::DSL

Defined in:
lib/trailblazer/1.1/operation/model/dsl.rb

Overview

Imports ::model and ::action into an operation.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(extender) ⇒ Object



5
6
7
8
9
# File 'lib/trailblazer/1.1/operation/model/dsl.rb', line 5

def self.extended(extender)
  extender.extend Uber::InheritableAttr
  extender.inheritable_attr :config
  extender.config = {}
end

Instance Method Details

#action(name) ⇒ Object



16
17
18
# File 'lib/trailblazer/1.1/operation/model/dsl.rb', line 16

def action(name)
  self.config[:action] = name
end

#action_nameObject

considered private.



20
21
22
# File 'lib/trailblazer/1.1/operation/model/dsl.rb', line 20

def action_name # considered private.
  self.config[:action] or :create
end

#model(name, action = nil) ⇒ Object



11
12
13
14
# File 'lib/trailblazer/1.1/operation/model/dsl.rb', line 11

def model(name, action=nil)
  self.config[:model] = name
  action(action) if action # coolest line ever.
end

#model_classObject

considered private.



24
25
26
# File 'lib/trailblazer/1.1/operation/model/dsl.rb', line 24

def model_class # considered private.
  self.config[:model] or raise "[Trailblazer] You didn't call Operation::model."
end