Class: RequestParamsValidation::Definitions::Resource
- Inherits:
-
Object
- Object
- RequestParamsValidation::Definitions::Resource
- Defined in:
- lib/request_params_validation/definitions/resource.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #action(action_name, &block) ⇒ Object
-
#initialize(name) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(name) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 |
# File 'lib/request_params_validation/definitions/resource.rb', line 9 def initialize(name) @name = name @actions = {} end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
7 8 9 |
# File 'lib/request_params_validation/definitions/resource.rb', line 7 def actions @actions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/request_params_validation/definitions/resource.rb', line 7 def name @name end |
Instance Method Details
#action(action_name, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/request_params_validation/definitions/resource.rb', line 14 def action(action_name, &block) unless block_given? raise DefinitionArgumentError.new("Expecting block for action '#{action_name}'") end action = Action.new(action_name.to_s) action.instance_eval(&block) @actions[action_name.to_s] = action rescue DefinitionArgumentError => e e.resource = name raise end |