Class: ActiveadminSettingsCached::Coercions
- Inherits:
-
Object
- Object
- ActiveadminSettingsCached::Coercions
- Defined in:
- lib/activeadmin_settings_cached/coercions.rb
Constant Summary collapse
- SIMPLE_COERCIONS =
{ float: :to_f, integer: :to_i, symbol: :to_sym }
Instance Attribute Summary collapse
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#display ⇒ Object
readonly
Returns the value of attribute display.
Instance Method Summary collapse
- #cast_params(params) ⇒ Object
-
#initialize(defaults, display) ⇒ Coercions
constructor
A new instance of Coercions.
Constructor Details
#initialize(defaults, display) ⇒ Coercions
Returns a new instance of Coercions.
10 11 12 13 14 15 |
# File 'lib/activeadmin_settings_cached/coercions.rb', line 10 def initialize(defaults, display) @defaults = defaults @display = display init_methods end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
8 9 10 |
# File 'lib/activeadmin_settings_cached/coercions.rb', line 8 def defaults @defaults end |
#display ⇒ Object (readonly)
Returns the value of attribute display.
8 9 10 |
# File 'lib/activeadmin_settings_cached/coercions.rb', line 8 def display @display end |
Instance Method Details
#cast_params(params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/activeadmin_settings_cached/coercions.rb', line 17 def cast_params(params) coerced_params = params.map do |name, value| [name, cast_value(name, value)] end return coerced_params unless block_given? coerced_params.each do |name, value| yield(name, value.call) end end |