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.34 lib/orkut/base.rb
orkut-0.0.0.33 lib/orkut/base.rb
orkut-0.0.0.32 lib/orkut/base.rb
orkut-0.0.0.31 lib/orkut/base.rb
orkut-0.0.0.30 lib/orkut/base.rb
orkut-0.0.0.29 lib/orkut/base.rb
orkut-0.0.0.28 lib/orkut/base.rb
orkut-0.0.0.27 lib/orkut/base.rb
orkut-0.0.0.26 lib/orkut/base.rb
orkut-0.0.0.25 lib/orkut/base.rb
orkut-0.0.0.24 lib/orkut/base.rb
orkut-0.0.0.23 lib/orkut/base.rb
orkut-0.0.0.22 lib/orkut/base.rb
orkut-0.0.0.21 lib/orkut/base.rb
orkut-0.0.0.20 lib/orkut/base.rb
orkut-0.0.0.19 lib/orkut/base.rb
orkut-0.0.0.18 lib/orkut/base.rb
orkut-0.0.0.17 lib/orkut/base.rb
orkut-0.0.0.16 lib/orkut/base.rb
orkut-0.0.0.15 lib/orkut/base.rb