Sha256: f89f17d542fd7a13e5f9b69e78e381daed854dad250ac97bc9bd73c8ad877bd6

Contents?: true

Size: 694 Bytes

Versions: 5

Compression:

Stored size: 694 Bytes

Contents

module ActiveRemote
  module Attributes
    # 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

Version Path
active_remote-1.8.1 lib/active_remote/attributes.rb
active_remote-1.8.0 lib/active_remote/attributes.rb
active_remote-1.8.0.rc1 lib/active_remote/attributes.rb
active_remote-1.7.1 lib/active_remote/attributes.rb
active_remote-1.7.0 lib/active_remote/attributes.rb