class A9n::Struct
Attributes
data[R]
to_h[R]
to_hash[R]
Public Class Methods
new(data = {})
click to toggle source
# File lib/a9n/struct.rb, line 9 def initialize(data = {}) @data = data end
Public Instance Methods
find(key)
click to toggle source
# File lib/a9n/struct.rb, line 20 def find(key) if key && data.key?(key.to_sym) fetch(key.to_sym) else raise KeyNotFoundError.new, "Could not find #{key} in #{data.keys.inspect}" end end
merge(another_data)
click to toggle source
# File lib/a9n/struct.rb, line 16 def merge(another_data) data.merge!(another_data) end
method_missing(key, *_args)
click to toggle source
# File lib/a9n/struct.rb, line 28 def method_missing(key, *_args) find(key) end
set(key, value)
click to toggle source
# File lib/a9n/struct.rb, line 32 def set(key, value) data[key.to_sym] = value end