class Fattr::List

Attributes

object[RW]

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/fattr.rb, line 12
def initialize(*args, &block)
  super(*args, &block)
end

Public Instance Methods

<<(element) click to toggle source
Calls superclass method
# File lib/fattr.rb, line 16
def << element
  super
  self
ensure
  uniq!
  index!
end
for(object) click to toggle source
# File lib/fattr.rb, line 49
def for(object)
  @object = object
  self
end
include?(element) click to toggle source
# File lib/fattr.rb, line 29
def include?(element)
  @index ||= Hash.new
  @index[element.to_s] ? true : false
end
index!() click to toggle source
# File lib/fattr.rb, line 24
def index!
  @index ||= Hash.new
  each{|element| @index[element.to_s] = true}
end
initializers() click to toggle source
# File lib/fattr.rb, line 34
def initializers
  @initializers ||= Hash.new
end
to_h() click to toggle source
# File lib/fattr.rb, line 45
def to_h
  to_hash
end
to_hash() click to toggle source
# File lib/fattr.rb, line 38
def to_hash
  if @object
    list = @object.class.fattrs + @object.fattrs
    list.inject(Hash.new){|hash, fattr| hash.update(fattr => @object.send(fattr))}
  end
end