Class: Croudia::Identity

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

Direct Known Subclasses

SecretMail, Status, User

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, #attrs

Constructor Details

#initializeIdentity

Returns a new instance of Identity.

Raises:

  • (ArgumentError)


5
6
7
8
9
# File 'lib/croudia/identity.rb', line 5

def initialize(*)
  super
  raise ArgumentError, 'argument must have an "id" key' unless id
  @attrs['id_str'] ||= id.to_s
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


13
14
15
# File 'lib/croudia/identity.rb', line 13

def ==(other)
  super || self.class == other.class && id == other.id
end

#idInteger

Returns:

  • (Integer)


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

def id
  @attrs['id'] || @attrs[:id]
end