Class: XCCache::HashRepresentable

Inherits:
Object
  • Object
show all
Defined in:
lib/xccache/core/syntax/hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, raw: nil) ⇒ HashRepresentable

Returns a new instance of HashRepresentable.



6
7
8
9
# File 'lib/xccache/core/syntax/hash.rb', line 6

def initialize(path, raw: nil)
  @path = path
  @raw = raw || load || {}
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/xccache/core/syntax/hash.rb', line 3

def path
  @path
end

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/xccache/core/syntax/hash.rb', line 4

def raw
  @raw
end

Instance Method Details

#[](key) ⇒ Object



27
28
29
# File 'lib/xccache/core/syntax/hash.rb', line 27

def [](key)
  raw[key]
end

#[]=(key, value) ⇒ Object



31
32
33
# File 'lib/xccache/core/syntax/hash.rb', line 31

def []=(key, value)
  raw[key] = value
end

#loadObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/xccache/core/syntax/hash.rb', line 15

def load
  raise NotImplementedError
end

#merge!(other) ⇒ Object



19
20
21
# File 'lib/xccache/core/syntax/hash.rb', line 19

def merge!(other)
  raw.merge!(other)
end

#reloadObject



11
12
13
# File 'lib/xccache/core/syntax/hash.rb', line 11

def reload
  @raw = load || {}
end

#save(to: nil) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/xccache/core/syntax/hash.rb', line 23

def save(to: nil)
  raise NotImplementedError
end