Class: CRStruct::Registered

Inherits:
Open
  • Object
show all
Defined in:
lib/crstruct/registered.rb

Instance Method Summary collapse

Methods inherited from Open

#get?, #method_missing, #set!, #to_h

Constructor Details

#initialize(h, *keys) ⇒ Registered

Registered.new :a, :b, :c, :d Registered.new 1, b: 2, :c, :d Registered.new 1, b: 2, [:c, :d] (*keys).flatten! should result to an Array(Symbol)



7
8
9
10
11
12
13
14
15
# File 'lib/crstruct/registered.rb', line 7

def initialize(h, *keys)
  keys.flatten!
  if h.is_a? Symbol
    keys.unshift(h)
    h = {}
  end
  @r = keys
  super(h)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CRStruct::Open

Instance Method Details

#free?(k) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/crstruct/registered.rb', line 17

def free?(k)
  return false unless @r.include? k
  super(k)
end