Class: ActionDSL
- Inherits:
-
Object
- Object
- ActionDSL
- Defined in:
- lib/cerulean.rb
Instance Method Summary collapse
- #form(key = nil, klass) ⇒ Object
-
#initialize(controller, name:, &block) ⇒ ActionDSL
constructor
A new instance of ActionDSL.
- #param(name, type = String, opts = {}) ⇒ Object
- #params(&block) ⇒ Object
- #presenter(presenter) ⇒ Object
- #request(&block) ⇒ Object
Constructor Details
#initialize(controller, name:, &block) ⇒ ActionDSL
Returns a new instance of ActionDSL.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cerulean.rb', line 4 def initialize(controller, name:, &block) @controller = controller @name = name @meta = {} instance_eval(&block) # yuck = @controller.class_variable_get(:@@meta) [name] = @meta @controller.class_variable_set(:@@meta, ) end |
Instance Method Details
#form(key = nil, klass) ⇒ Object
30 31 32 |
# File 'lib/cerulean.rb', line 30 def form(key=nil, klass) @meta[:form] = { key: key, klass: klass } end |
#param(name, type = String, opts = {}) ⇒ Object
21 22 23 24 |
# File 'lib/cerulean.rb', line 21 def param(name, type=String, opts={}) @meta[:params] ||= {} @meta[:params][name] = opts.merge({ type: type }) end |
#params(&block) ⇒ Object
17 18 19 |
# File 'lib/cerulean.rb', line 17 def params(&block) instance_eval(&block) end |
#presenter(presenter) ⇒ Object
26 27 28 |
# File 'lib/cerulean.rb', line 26 def presenter(presenter) @meta[:presenter] = presenter end |
#request(&block) ⇒ Object
34 35 36 |
# File 'lib/cerulean.rb', line 34 def request(&block) @controller.send(:define_method, @name, &block) end |