Sha256: 58bf4e04f95260c15798860f53215c5ba3260e6ef46297ca0d5b31a575638c0d

Contents?: true

Size: 453 Bytes

Versions: 34

Compression:

Stored size: 453 Bytes

Contents

module Orkut
  class Base

    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

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

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

  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
orkut-0.0.0.14 lib/orkut/base.rb
orkut-0.0.0.13 lib/orkut/base.rb
orkut-0.0.0.12 lib/orkut/base.rb
orkut-0.0.0.11 lib/orkut/base.rb
orkut-0.0.0.10 lib/orkut/base.rb
orkut-0.0.0.9 lib/orkut/base.rb
orkut-0.0.0.8 lib/orkut/base.rb
orkut-0.0.0.7 lib/orkut/base.rb
orkut-0.0.0.6 lib/orkut/base.rb
orkut-0.0.0.5 lib/orkut/base.rb
orkut-0.0.0.4 lib/orkut/base.rb
orkut-0.0.0.3 lib/orkut/base.rb
orkut-0.0.0.2 lib/orkut/base.rb
orkut-0.0.0.1 lib/orkut/base.rb