Class: Betterdocs::Dsl::JsonParams::Param
- Inherits:
-
Representer
- Object
- Representer
- Betterdocs::Dsl::JsonParams::Param
- Extended by:
- Tins::DSLAccessor
- Defined in:
- lib/betterdocs/dsl/json_params/param.rb
Instance Attribute Summary
Attributes included from Naming
Attributes inherited from Representer
Instance Method Summary collapse
- #add_to_collector(collector) ⇒ Object
- #assign(result, object) ⇒ Object
- #compute_value(object) ⇒ Object
-
#initialize(representer, name, options, &block) ⇒ Param
constructor
A new instance of Param.
Methods included from Naming
#below_path, #full_name, #nesting_name, #path, #public_name
Methods included from Common
Methods inherited from Representer
Constructor Details
#initialize(representer, name, options, &block) ⇒ Param
Returns a new instance of Param.
14 15 16 17 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 14 def initialize(representer, name, , &block) super types Betterdocs::Dsl::JsonTypeMapper.map_types(types) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Betterdocs::Dsl::Common
Instance Method Details
#add_to_collector(collector) ⇒ Object
28 29 30 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 28 def add_to_collector(collector) collector.params[name] = self end |
#assign(result, object) ⇒ Object
19 20 21 22 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 19 def assign(result, object) assign?(object) or return result[name] = compute_value(object) end |
#compute_value(object) ⇒ Object
24 25 26 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 24 def compute_value(object) object.__send__(name) end |