Sha256: 7551f0fb56d535ca7d2358022903db4ad865138742ac77a5dde3ad85bb96fadf

Contents?: true

Size: 735 Bytes

Versions: 3

Compression:

Stored size: 735 Bytes

Contents

module ActiveRemote
  module Attributes
    # Read attribute from the attributes hash
    #
    def read_attribute(name)
      name = name.to_s

      if respond_to? name
        @attributes[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}="
        @attributes[name] = typecast_attribute(_attribute_typecaster(name), value)
      else
        raise ::ActiveAttr::UnknownAttributeError, "unknown attribute: #{name}"
      end
    end
    alias_method :[]=, :write_attribute
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_remote-1.6.1 lib/active_remote/attributes.rb
active_remote-1.6.0 lib/active_remote/attributes.rb
active_remote-1.5.9 lib/active_remote/attributes.rb