Class: Jinx::Writable

Inherits:
Associative show all
Defined in:
lib/jinx/helpers/associative.rb

Instance Method Summary collapse

Methods inherited from Associative

#writer

Constructor Details

#initialize(base, &writer) ⇒ Writable

Returns a new instance of Writable.



28
29
30
31
# File 'lib/jinx/helpers/associative.rb', line 28

def initialize(base, &writer)
  @base = base
  @writer = writer
end

Instance Method Details

#[](key) ⇒ Object



33
34
35
# File 'lib/jinx/helpers/associative.rb', line 33

def [](key)
  @base[key]
end

#[]=(key, value) ⇒ Object



37
38
39
# File 'lib/jinx/helpers/associative.rb', line 37

def []=(key, value)
  @writer.call(key, value)
end