Class: CRStruct::Registered

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

Instance Method Summary collapse

Methods inherited from Open

#method_missing

Constructor Details

#initialize(*keys) ⇒ Registered

Returns a new instance of Registered.



13
14
15
# File 'lib/crstruct.rb', line 13

def initialize(*keys)
  @keys = keys
end

Dynamic Method Handling

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

Instance Method Details

#define_singleton_method(k, &blk) ⇒ Object

Raises:

  • (KeyError)


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

def define_singleton_method(k,&blk)
  raise KeyError, "can't add unregistered key: :#{k}" unless @keys.include? k
  super(k,&blk)
end