class Hashie::Trash
def self.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 self.property(property_name, options = {}) super if options[:from] if property_name.to_sym == options[:from].to_sym raise ArgumentError, "Property name (#{property_name}) and :from option must not be the same" end translations << options[:from].to_sym if options[:with].respond_to? :call class_eval do define_method "#{options[:from]}=" do |val| self[property_name.to_sym] = options[:with].call(val) end end else class_eval <<-RUBY def #{options[:from]}=(val) self[:#{property_name}] = val end RUBY end elsif options[:transform_with].respond_to? :call transforms[property_name.to_sym] = options[:transform_with] end end