Sha256: 50bb7bd173c953698ade23104aa759dfca07a04619d004c752b0e00fb6890f91
Contents?: true
Size: 892 Bytes
Versions: 5
Compression:
Stored size: 892 Bytes
Contents
module ActiveRemote module Attributes def attributes @attributes ||= begin attribute_names = self.class.attribute_names Hash[attribute_names.map { |key| [key, send(key)] }] end @attributes.dup end # Read attribute from the attributes hash # def read_attribute(name) name = name.to_s if respond_to? name attribute(name) else raise ActiveAttr::UnknownAttributeError, "unknown attribute: #{name}" end end alias_method :[], :read_attribute # Update an attribute in the attributes hash # def write_attribute(name, value) name = name.to_s if respond_to? "#{name}=" __send__("attribute=", name, value) else raise ActiveAttr::UnknownAttributeError, "unknown attribute: #{name}" end end alias_method :[]=, :write_attribute end end
Version data entries
5 entries across 5 versions & 1 rubygems