module Hashie::Extensions::Dash::PropertyTranslation::ClassMethods
def property(property_name, options = {})
* :transform_with - Specify a lambda to be used to convert value
* :with - Specify a lambda to be used to convert value.
* :from - Specify the original key name that will be write only.
returned before a value is set on the property in a new Dash.
* :default - Specify a default value for this property, to be
Defines a property on the Trash. Options are as follows:
def property(property_name, options = {}) super if options[:from] if property_name == options[:from] fail ArgumentError, "Property name (#{property_name}) and :from option must not be the same" end translations_hash[options[:from]] ||= {} translations_hash[options[:from]][property_name] = options[:with] || options[:transform_with] define_method "#{options[:from]}=" do |val| self.class.translations_hash[options[:from]].each do |name, with| self[name] = with.respond_to?(:call) ? with.call(val) : val end end else if options[:transform_with].respond_to? :call transforms[property_name] = options[:transform_with] end end end