Class: CouchPotato::Persistence::Properties::PropertyList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/couch_potato/persistence/properties.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz) ⇒ PropertyList

Returns a new instance of PropertyList.



11
12
13
14
# File 'lib/couch_potato/persistence/properties.rb', line 11

def initialize(clazz)
  @clazz = clazz
  @list = []
end

Instance Attribute Details

#listObject

Returns the value of attribute list.



9
10
11
# File 'lib/couch_potato/persistence/properties.rb', line 9

def list
  @list
end

Instance Method Details

#<<(property) ⇒ Object



20
21
22
# File 'lib/couch_potato/persistence/properties.rb', line 20

def <<(property)
  @list << property
end

#eachObject



16
17
18
# File 'lib/couch_potato/persistence/properties.rb', line 16

def each
  (list + inherited_properties).each {|property| yield property}
end

#inherited_propertiesObject



24
25
26
27
28
29
30
31
32
# File 'lib/couch_potato/persistence/properties.rb', line 24

def inherited_properties
  superclazz = @clazz.superclass
  properties = []
  while superclazz && superclazz.respond_to?(:properties)
    properties << superclazz.properties.list
    superclazz = superclazz.superclass
  end
  properties.flatten
end