Sha256: bca0f3e25754d41ca7bd3b2458235bb99006a825bc33dfcb0629060edf7b6160

Contents?: true

Size: 613 Bytes

Versions: 2

Compression:

Stored size: 613 Bytes

Contents

module ROM
  # Simple data-struct
  #
  # By default mappers use this as the model
  #
  # @api public
  class Struct
    # Coerces a struct to a hash
    #
    # @return [Hash]
    #
    # @api private
    def to_hash
      to_h
    end

    # Reads an attribute value
    #
    # @param name [Symbol] The name of the attribute
    #
    # @return [Object]
    #
    # @api public
    def [](name)
      __send__(name)
    end

    # Returns a short string representation
    #
    # @return [String]
    #
    # @api public
    def to_s
      "#<#{self.class}:0x#{(object_id << 1).to_s(16)}>"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-repository-0.3.1 lib/rom/struct.rb
rom-repository-0.3.0 lib/rom/struct.rb