Sha256: 605bd7b809ef85e76d3399dc9b0daa83752eb583f8ede539e21392d77e00265f

Contents?: true

Size: 707 Bytes

Versions: 15

Compression:

Stored size: 707 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 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 UnknownAttributeError, "unknown attribute: #{name}"
      end
    end
    alias_method :[]=, :write_attribute
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_remote-1.5.8 lib/active_remote/attributes.rb
active_remote-1.5.7 lib/active_remote/attributes.rb
active_remote-1.5.6 lib/active_remote/attributes.rb
active_remote-1.5.5 lib/active_remote/attributes.rb
active_remote-1.5.4 lib/active_remote/attributes.rb
active_remote-1.5.2 lib/active_remote/attributes.rb
active_remote-1.5.1 lib/active_remote/attributes.rb
active_remote-1.5.0 lib/active_remote/attributes.rb
active_remote-1.4.1 lib/active_remote/attributes.rb
active_remote-1.4.0 lib/active_remote/attributes.rb
active_remote-1.3.3 lib/active_remote/attributes.rb
active_remote-1.3.2 lib/active_remote/attributes.rb
active_remote-1.3.1 lib/active_remote/attributes.rb
active_remote-1.3.0 lib/active_remote/attributes.rb
active_remote-1.2.1 lib/active_remote/attributes.rb