Class: AttributesReader::Attributes

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

Instance Method Summary collapse

Constructor Details

#initialize(parent_object) ⇒ Attributes

Returns a new instance of Attributes.



5
6
7
# File 'lib/attributes_reader.rb', line 5

def initialize parent_object
  @parent_object = parent_object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/attributes_reader.rb', line 9

def method_missing(m, *args, &block)
  if @parent_object.methods.include?("#{m}_expr".intern)
    @parent_object.send("#{m}_expr", *args)
  else
    raise MissingAttributeError.new(m, @parent_object.class)
  end
end