Class: Macaroons::Macaroon

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/macaroons/macaroons.rb

Direct Known Subclasses

Macaroon

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: nil, identifier: nil, location: nil, raw_macaroon: nil) ⇒ Macaroon

Returns a new instance of Macaroon.



9
10
11
# File 'lib/macaroons/macaroons.rb', line 9

def initialize(key: nil, identifier: nil, location: nil, raw_macaroon: nil)
  @raw_macaroon = raw_macaroon || RawMacaroon.new(key: key, identifier: identifier, location: location)
end

Class Method Details

.from_binary(serialized) ⇒ Object



16
17
18
19
# File 'lib/macaroons/macaroons.rb', line 16

def self.from_binary(serialized)
  raw_macaroon = RawMacaroon.from_binary(serialized: serialized)
  macaroon = Macaroons::Macaroon.new(raw_macaroon: raw_macaroon)
end

.from_json(serialized) ⇒ Object



21
22
23
24
# File 'lib/macaroons/macaroons.rb', line 21

def self.from_json(serialized)
  raw_macaroon = RawMacaroon.from_json(serialized: serialized)
  macaroon = Macaroons::Macaroon.new(raw_macaroon: raw_macaroon)
end

Instance Method Details

#first_party_caveatsObject



26
27
28
# File 'lib/macaroons/macaroons.rb', line 26

def first_party_caveats
  caveats.select(&:first_party?)
end

#third_party_caveatsObject



30
31
32
# File 'lib/macaroons/macaroons.rb', line 30

def third_party_caveats
  caveats.select(&:third_party?)
end