Class: SimplyCouch::Model::Persistence::Properties::PropertyList
- Inherits:
-
Object
- Object
- SimplyCouch::Model::Persistence::Properties::PropertyList
- Includes:
- Enumerable
- Defined in:
- lib/simply_couch/model/persistence.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
Instance Method Summary collapse
- #<<(property) ⇒ Object
- #each(&block) ⇒ Object
- #find_property(name) ⇒ Object
- #inherited_properties ⇒ Object
-
#initialize(clazz) ⇒ PropertyList
constructor
A new instance of PropertyList.
- #inspect ⇒ Object
Constructor Details
#initialize(clazz) ⇒ PropertyList
Returns a new instance of PropertyList.
80 81 82 83 84 |
# File 'lib/simply_couch/model/persistence.rb', line 80 def initialize(clazz) @clazz = clazz @list = [] @hash = {} end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
78 79 80 |
# File 'lib/simply_couch/model/persistence.rb', line 78 def list @list end |
Instance Method Details
#<<(property) ⇒ Object
87 |
# File 'lib/simply_couch/model/persistence.rb', line 87 def <<(property); @hash[property.name] = property; @list << property; end |
#each(&block) ⇒ Object
86 |
# File 'lib/simply_couch/model/persistence.rb', line 86 def each(&block); (list + inherited_properties).each(&block); end |
#find_property(name) ⇒ Object
88 |
# File 'lib/simply_couch/model/persistence.rb', line 88 def find_property(name); @hash[name] || @clazz.superclass.properties.find_property(name); end |
#inherited_properties ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/simply_couch/model/persistence.rb', line 91 def inherited_properties superclazz = @clazz.superclass properties = [] while superclazz && superclazz.respond_to?(:properties) properties << superclazz.properties.list superclazz = superclazz.superclass end properties.flatten end |
#inspect ⇒ Object
89 |
# File 'lib/simply_couch/model/persistence.rb', line 89 def inspect; list.map(&:name).inspect; end |