Class: CRStruct::Registered
Instance Method Summary collapse
- #free?(k) ⇒ Boolean
-
#initialize(h, *keys) ⇒ Registered
constructor
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).
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
17 18 19 20 |
# File 'lib/crstruct/registered.rb', line 17 def free?(k) return false unless @r.include? k super(k) end |