Class: Cookie::Header::Attribute::Set

Inherits:
Object
  • Object
show all
Includes:
Adamantium, Enumerable
Defined in:
lib/cookie/header/attribute.rb

Overview

Models a set of attributes used within a Serializable cookie

Direct Known Subclasses

Empty

Defined Under Namespace

Classes: Empty

Constant Summary collapse

EMPTY =

class Empty

Empty.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.coerce(attributes) ⇒ Object



37
38
39
40
41
42
# File 'lib/cookie/header/attribute.rb', line 37

def self.coerce(attributes)
  new(attributes.each_with_object({}) { |(name, value), hash|
    attribute = Attribute.coerce(name, value)
    hash[attribute.name] = attribute if attribute
  })
end

Instance Method Details

#each(&block) ⇒ Object



44
45
46
47
48
# File 'lib/cookie/header/attribute.rb', line 44

def each(&block)
  return to_enum unless block
  attributes.each_value(&block)
  self
end

#merge(attribute) ⇒ Object



50
51
52
# File 'lib/cookie/header/attribute.rb', line 50

def merge(attribute)
  Set.new(attributes.merge(attribute.name => attribute))
end

#to_sObject



54
55
56
# File 'lib/cookie/header/attribute.rb', line 54

def to_s
  "#{COOKIE_SEPARATOR}#{map(&:to_s).join(COOKIE_SEPARATOR)}"
end