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

- (PropertyList) initialize(clazz)

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

- (Object) list

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

- (Object) <<(property)



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

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

- (Object) each



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

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

- (Object) inherited_properties



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

- (Object) inspect

XXX



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

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