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.
16 17 18 19 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 16 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
21 22 23 24 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 21 def assign(result, object) assign?(object) or return result[name] = compute_value(object) end |
#compute_value(object) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/betterdocs/dsl/json_params/param.rb', line 26 def compute_value(object) value = object.__send__(name) if ActiveSupport::TimeWithZone === value value.extend Betterdocs::JsonTimeWithZone end value end |