Sha256: ea9bd34fbd0dba5621fa28f3a8368c837381543c39e0444dffca07472da6c41f

Contents?: true

Size: 588 Bytes

Versions: 3

Compression:

Stored size: 588 Bytes

Contents

module AttrMethods
  
  def attr_array(*names)
    names.each do |n|
      self.send :define_method, n do |*value|
        instance_variable_set "@#{n}", value
      end
      self.send :define_method, "#{n}=" do |value|
        instance_variable_set "@#{n}", value
      end
    end
  end
  
  def attr_hash(*names)
  	names.each do |n|
      self.send :define_method, n do |value|
        instance_variable_set "@#{n}", value
      end
      self.send :define_method, "#{n}=" do |value|
        instance_variable_set "@#{n}", value
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
albacore-0.1.2 lib/albacore/support/attrmethods.rb
albacore-0.1.1 lib/albacore/support/attrmethods.rb
albacore-0.1.0 lib/albacore/support/attrmethods.rb