Class: ACTV::Identity

Inherits:
Base
  • Object
show all
Defined in:
lib/actv/identity.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, #delete, from_response, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, #update, uri_attr_reader

Constructor Details

#initialize(attrs = {}) ⇒ ACTV::Base

Initializes a new object

Parameters:

  • attrs (Hash) (defaults to: {})

Raises:

  • (ArgumentError)

    Error raised when supplied argument is missing an :id key.



11
12
13
14
# File 'lib/actv/identity.rb', line 11

def initialize(attrs={})
  super
  raise ArgumentError, 'argument must have an :id key' unless id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ACTV::Base

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


18
19
20
# File 'lib/actv/identity.rb', line 18

def ==(other)
  super || attr_equal(:id, other) || attrs_equal(other)
end

#idInteger

Returns:

  • (Integer)


23
24
25
# File 'lib/actv/identity.rb', line 23

def id
  @attrs[:id]
end