Class: Interapp::Peer

Inherits:
Object
  • Object
show all
Defined in:
app/models/interapp/peer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Peer

Returns a new instance of Peer.



5
6
7
# File 'app/models/interapp/peer.rb', line 5

def initialize(attributes = {})
  attributes.each { |name, value| send("#{name}=", value) }
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



3
4
5
# File 'app/models/interapp/peer.rb', line 3

def endpoint
  @endpoint
end

#identifierObject

Returns the value of attribute identifier.



3
4
5
# File 'app/models/interapp/peer.rb', line 3

def identifier
  @identifier
end

#public_keyObject

Returns the value of attribute public_key.



3
4
5
# File 'app/models/interapp/peer.rb', line 3

def public_key
  @public_key
end

Class Method Details

.allObject



15
16
17
# File 'app/models/interapp/peer.rb', line 15

def self.all
  Interapp.configuration.peers
end

.find(identifier) ⇒ Object



19
20
21
# File 'app/models/interapp/peer.rb', line 19

def self.find(identifier)
  self.all.find{ |peer| peer.identifier == identifier }
end

Instance Method Details

#public_key_decodedObject



9
10
11
12
13
# File 'app/models/interapp/peer.rb', line 9

def public_key_decoded
  @public_key_decoded ||= ECDSA::Format::PointOctetString.decode(
    [public_key].pack("H*"), Interapp::EC_GROUP
  )
end