Class: Moonrope::DSL::ActionDSL
- Inherits:
-
Object
- Object
- Moonrope::DSL::ActionDSL
- Defined in:
- lib/moonrope/dsl/action_dsl.rb
Instance Method Summary collapse
-
#access(value = nil) { ... } ⇒ void
Set the access condition for the action.
-
#action { ... } ⇒ void
Set the action to execute when this action is invoked.
-
#description(value) ⇒ void
Set the description for the action.
-
#initialize(action) ⇒ ActionDSL
constructor
Initialize a new ActionDSL.
-
#param(name, description, options = {}) ⇒ void
Add a new param to the action’s param set.
Constructor Details
#initialize(action) ⇒ ActionDSL
Initialize a new ActionDSL
10 11 12 |
# File 'lib/moonrope/dsl/action_dsl.rb', line 10 def initialize(action) @action = action end |
Instance Method Details
#access(value = nil) { ... } ⇒ void
This method returns an undefined value.
Set the access condition for the action.
access do
auth.is_a?(User)
end
50 51 52 |
# File 'lib/moonrope/dsl/action_dsl.rb', line 50 def access(value = nil, &block) @action.access = block_given? ? block : value end |
#action { ... } ⇒ void
This method returns an undefined value.
Set the action to execute when this action is invoked.
action do
# Do something here and return a JSON-able value
end
64 65 66 |
# File 'lib/moonrope/dsl/action_dsl.rb', line 64 def action(&block) @action.action = block end |
#description(value) ⇒ void
This method returns an undefined value.
Set the description for the action
description "Returns all users which are configured"
22 23 24 |
# File 'lib/moonrope/dsl/action_dsl.rb', line 22 def description(value) @action.description = value end |
#param(name, description, options = {}) ⇒ void
This method returns an undefined value.
Add a new param to the action’s param set.
param :page, "The page number", :default => 2
36 37 38 |
# File 'lib/moonrope/dsl/action_dsl.rb', line 36 def param(name, description, = {}) @action.params[name] = .merge(:description => description) end |