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.
18 19 20 21 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 18 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
34 35 36 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 34 def add_to_collector(collector) collector.params[name] = self end |
#assign(result, object) ⇒ Object
23 24 25 26 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 23 def assign(result, object) assign?(object) or return result[name] = compute_value(object) end |
#compute_value(object) ⇒ Object
28 29 30 31 32 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 28 def compute_value(object) value = object.__send__(name) value.respond_to?(:iso8601) and value.extend Betterdocs::JsonTimeWithZone value end |