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



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

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

Instance Attribute Details

#listObject

Returns the value of attribute list



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

def list
  @list
end

Instance Method Details

#<<(property) ⇒ Object



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

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

#eachObject



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

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

#inherited_propertiesObject



30
31
32
33
34
35
36
37
38
# File 'lib/couch_potato/persistence/properties.rb', line 30

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

#inspectObject

XXX



26
27
28
# File 'lib/couch_potato/persistence/properties.rb', line 26

def inspect
  list.map(&:name).inspect
end