Class: FinerStruct::Immutable

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

Direct Known Subclasses

Mutable

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Immutable

Returns a new instance of Immutable.



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

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments) ⇒ Object



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

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