Class: Orkut::Base

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
# File 'lib/orkut/base.rb', line 14

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

Class Method Details

.lazy_attr_reader(*attributes) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/orkut/base.rb', line 4

def self.lazy_attr_reader(*attributes)
  attributes.each do |attribute|
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{attribute}
        @#{attribute} ||= @attributes[#{attribute.to_s.inspect}]
      end
    RUBY
  end
end

Instance Method Details

#[](method) ⇒ Object



18
19
20
# File 'lib/orkut/base.rb', line 18

def [](method)
  self.__send__(method.to_sym)
end