class ActionDSL
Public Class Methods
new(controller, name:, &block)
click to toggle source
# File lib/cerulean.rb, line 4 def initialize(controller, name:, &block) @controller = controller @name = name @meta = {} instance_eval(&block) # yuck meta = @controller.class_variable_get(:@@meta) meta[name] = @meta @controller.class_variable_set(:@@meta, meta) end
Public Instance Methods
form(key=nil, klass)
click to toggle source
# File lib/cerulean.rb, line 30 def form(key=nil, klass) @meta[:form] = { key: key, klass: klass } end
param(name, type=String, opts={})
click to toggle source
# File lib/cerulean.rb, line 21 def param(name, type=String, opts={}) @meta[:params] ||= {} @meta[:params][name] = opts.merge({ type: type }) end
params(&block)
click to toggle source
# File lib/cerulean.rb, line 17 def params(&block) instance_eval(&block) end
presenter(presenter)
click to toggle source
# File lib/cerulean.rb, line 26 def presenter(presenter) @meta[:presenter] = presenter end
request(&block)
click to toggle source
# File lib/cerulean.rb, line 34 def request(&block) @controller.send(:define_method, @name, &block) end