Sha256: ee59e3900c042d3170c354d6eae02bf8464299a9b7b400aa617f4595966b88a1
Contents?: true
Size: 964 Bytes
Versions: 1
Compression:
Stored size: 964 Bytes
Contents
module Recliner module AttributeMethods module Write extend ActiveSupport::Concern included do attribute_method_suffix "=" end # Updates the attribute identified by <tt>name</tt> with the specified +value+. # Values are typecast to the appropriate type determined by the property. def write_attribute(name, value) if prop = property(name) attributes[prop.as] = prop.type_cast(value) else attributes[name.to_s] = value end value end # Updates the attribute identified by <tt>name</tt> with the specified +value+. # (Alias for the protected write_attribute method). def []=(name, value) write_attribute(name, value) end private # Handle *= for method_missing. def attribute=(attribute_name, value) write_attribute(attribute_name, value) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
recliner-0.0.1 | lib/recliner/attribute_methods/write.rb |