Class: Pastore::Params::ActionParam
- Inherits:
-
Object
- Object
- Pastore::Params::ActionParam
- Defined in:
- lib/pastore/params/action_param.rb
Overview
Stores data about action parameters
Constant Summary collapse
- AVAILABLE_TYPES =
%w[string number boolean date object array any].freeze
- TYPE_ALIASES =
{ 'text' => 'string', 'integer' => 'number', 'float' => 'number', 'hash' => 'object' }.freeze
Instance Attribute Summary collapse
-
#modifier ⇒ Object
readonly
Returns the value of attribute modifier.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #array? ⇒ Boolean
-
#initialize(name, **options) ⇒ ActionParam
constructor
A new instance of ActionParam.
- #name_with_scope ⇒ Object
- #validate(value) ⇒ Object
Constructor Details
#initialize(name, **options) ⇒ ActionParam
Returns a new instance of ActionParam.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pastore/params/action_param.rb', line 17 def initialize(name, **) @name = name = @scope = [&.fetch(:scope, nil)].flatten.compact @array = &.fetch(:array, false) == true @modifier = &.fetch(:modifier, nil) @type = &.fetch(:type, :any) end |
Instance Attribute Details
#modifier ⇒ Object (readonly)
Returns the value of attribute modifier.
15 16 17 |
# File 'lib/pastore/params/action_param.rb', line 15 def modifier @modifier end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/pastore/params/action_param.rb', line 15 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/pastore/params/action_param.rb', line 15 def end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
15 16 17 |
# File 'lib/pastore/params/action_param.rb', line 15 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/pastore/params/action_param.rb', line 15 def type @type end |
Instance Method Details
#array? ⇒ Boolean
32 33 34 |
# File 'lib/pastore/params/action_param.rb', line 32 def array? @array end |
#name_with_scope ⇒ Object
36 37 38 |
# File 'lib/pastore/params/action_param.rb', line 36 def name_with_scope [@scope, name].flatten.compact.join('.') end |
#validate(value) ⇒ Object
28 29 30 |
# File 'lib/pastore/params/action_param.rb', line 28 def validate(value) Pastore::Params::Validation.validate!(name, type, value, modifier, **) end |