Class: RailsSettingsUi::ValueTypes::Hash
- Defined in:
- lib/rails-settings-ui/value_types/hash.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #valid?, #value_numeric?
Constructor Details
This class inherits a constructor from RailsSettingsUi::ValueTypes::Base
Instance Method Details
#cast ⇒ Object
6 7 8 |
# File 'lib/rails-settings-ui/value_types/hash.rb', line 6 def cast value end |
#validate ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rails-settings-ui/value_types/hash.rb', line 10 def validate begin self.value = JSON.parse(value.gsub(/\=\>/, ':')) rescue JSON::ParserError => e self.errors << I18n.t('errors.invalid_hash', default: 'Invalid') end end |