Class: RedSnow::KeyValueCollection Abstract
- Inherits:
-
BlueprintNode
- Object
- BlueprintNode
- RedSnow::KeyValueCollection
- Defined in:
- lib/redsnow/blueprint.rb
Overview
This class is abstract.
Blueprint AST node for key-value collections
Instance Attribute Summary collapse
-
#collection ⇒ Array<Hash>
array of key value hashes.
Instance Method Summary collapse
-
#[](key) ⇒ NilClass, String
Retrieves the value of the collection item by its key.
-
#filter_collection(ignore_keys) ⇒ Array<Hash>
Filter collection keys.
Instance Attribute Details
#collection ⇒ Array<Hash>
array of key value hashes
58 59 60 |
# File 'lib/redsnow/blueprint.rb', line 58 def collection @collection end |
Instance Method Details
#[](key) ⇒ NilClass, String
Retrieves the value of the collection item by its key
67 68 69 70 |
# File 'lib/redsnow/blueprint.rb', line 67 def [] key return nil if @collection.nil? return_item_value key end |
#filter_collection(ignore_keys) ⇒ Array<Hash>
Filter collection keys
74 75 76 77 |
# File 'lib/redsnow/blueprint.rb', line 74 def filter_collection(ignore_keys) return @collection if ignore_keys.blank? @collection.select { |kv_item| !ignore_keys.include?(kv_item.keys.first) } end |