Sha256: db78c67fa85e9f4a4a532227e23c3fa883e19595456fb5cf85d8ffb9e0befb75

Contents?: true

Size: 436 Bytes

Versions: 4

Compression:

Stored size: 436 Bytes

Contents

# Dynamically define class attribute accessors
module ClassAttr

  def self.included klass
    klass.extend ClassMethods
  end

  module ClassMethods

    def class_attr *list
      list.each do |my_method|
        eval "
          def self.#{my_method}= #{my_method}
            @#{my_method} = #{my_method}
          end
          def self.#{my_method}
            @#{my_method}
          end
        "
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atesta-0.0.4 lib/class_attr.rb
atesta-0.0.3 lib/class_attr.rb
atesta-0.0.2 lib/class_attr.rb
atesta-0.0.1 lib/class_attr.rb