Class: Kartograph::PropertyCollection
- Inherits:
-
Object
- Object
- Kartograph::PropertyCollection
- Extended by:
- Forwardable
- Defined in:
- lib/kartograph/property_collection.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #filter_by_scope(scope) ⇒ Object
-
#initialize ⇒ PropertyCollection
constructor
A new instance of PropertyCollection.
Constructor Details
#initialize ⇒ PropertyCollection
Returns a new instance of PropertyCollection.
10 11 12 13 |
# File 'lib/kartograph/property_collection.rb', line 10 def initialize(*) @collection = [] @cache = {} end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/kartograph/property_collection.rb', line 27 def ==(other) each_with_index.inject(true) do |current_value, (property, index)| break unless current_value property == other[index] end end |
#filter_by_scope(scope) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kartograph/property_collection.rb', line 15 def filter_by_scope(scope) if @cache.has_key? scope return @cache[scope] end @cache[scope] = select do |property| property.scopes.include?(scope) end @cache[scope] end |