Class: FinerStruct::Immutable

Inherits:
Object
  • Object
show all
Defined in:
lib/finer_struct/immutable.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Immutable

Returns a new instance of Immutable.



6
7
8
9
# File 'lib/finer_struct/immutable.rb', line 6

def initialize(attributes = {})
  @attributes = attributes.dup.freeze
  freeze
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/finer_struct/immutable.rb', line 11

def method_missing(method, *arguments)
  if @attributes.has_key?(method)
    @attributes[method]
  else
    super
  end
end