Class: Nasty::Key

Inherits:
Object show all
Defined in:
lib/nasty/key.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Key

Returns a new instance of Key.



3
4
5
# File 'lib/nasty/key.rb', line 3

def initialize(key)
  @key = key
end

Instance Method Details

#add_to(store, value) ⇒ Object



7
8
9
# File 'lib/nasty/key.rb', line 7

def add_to(store, value)
  store[to_sym] = value
end

#contained_in?(store) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/nasty/key.rb', line 15

def contained_in?(store)
  item_from(store)
end

#item_from(store) ⇒ Object



19
20
21
# File 'lib/nasty/key.rb', line 19

def item_from(store)
  store[to_sym]
end

#remove_from(store) ⇒ Object



11
12
13
# File 'lib/nasty/key.rb', line 11

def remove_from(store)
  store[to_sym] = nil
end

#to_symObject



23
24
25
# File 'lib/nasty/key.rb', line 23

def to_sym
  @key.to_sym
end