Class: Fleck::Core::Consumer::ActionParam
- Inherits:
-
Object
- Object
- Fleck::Core::Consumer::ActionParam
- Defined in:
- lib/fleck/core/consumer/action_param.rb
Overview
Stores data about an action parameter, which will be used for automatic parameters validation.
Constant Summary collapse
- AVAILABLE_TYPES =
%w[string number boolean object array].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.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, modifier = nil, **options) ⇒ ActionParam
constructor
A new instance of ActionParam.
- #required? ⇒ Boolean
- #string? ⇒ Boolean
- #validate(value) ⇒ Object
Constructor Details
#initialize(name, modifier = nil, **options) ⇒ ActionParam
Returns a new instance of ActionParam.
18 19 20 21 22 23 24 25 |
# File 'lib/fleck/core/consumer/action_param.rb', line 18 def initialize(name, modifier = nil, **) @name = name @options = @modifier = modifier @type = @options&.fetch(:type) end |
Instance Attribute Details
#modifier ⇒ Object (readonly)
Returns the value of attribute modifier.
16 17 18 |
# File 'lib/fleck/core/consumer/action_param.rb', line 16 def modifier @modifier end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/fleck/core/consumer/action_param.rb', line 16 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/fleck/core/consumer/action_param.rb', line 16 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/fleck/core/consumer/action_param.rb', line 16 def type @type end |
Instance Method Details
#required? ⇒ Boolean
31 32 33 |
# File 'lib/fleck/core/consumer/action_param.rb', line 31 def required? [:required] end |
#string? ⇒ Boolean
27 28 29 |
# File 'lib/fleck/core/consumer/action_param.rb', line 27 def string? @type == 'string' end |
#validate(value) ⇒ Object
35 36 37 |
# File 'lib/fleck/core/consumer/action_param.rb', line 35 def validate(value) Validation.new(name, type, value, modifier, **) end |