Class: ActiveMocker::ModelSchemaCollection Private
- Inherits:
-
Object
- Object
- ActiveMocker::ModelSchemaCollection
- Includes:
- Enumerable
- Defined in:
- lib/active_mocker/model_schema.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #collection ⇒ Object private
Instance Method Summary collapse
- #[](val) ⇒ Object private
- #each(&block) ⇒ Object private
- #find_by(options = {}) ⇒ Object private
- #find_by_in_relationships(options = {}) ⇒ Object private
-
#initialize(collection) ⇒ ModelSchemaCollection
constructor
private
A new instance of ModelSchemaCollection.
Constructor Details
#initialize(collection) ⇒ ModelSchemaCollection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ModelSchemaCollection.
22 23 24 |
# File 'lib/active_mocker/model_schema.rb', line 22 def initialize(collection) @collection = collection end |
Instance Attribute Details
#collection ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/active_mocker/model_schema.rb', line 20 def collection @collection end |
Instance Method Details
#[](val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/active_mocker/model_schema.rb', line 47 def [](val) collection[val] end |
#each(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 |
# File 'lib/active_mocker/model_schema.rb', line 26 def each(&block) collection.each do |item| block.call(item) end end |
#find_by(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/active_mocker/model_schema.rb', line 32 def find_by(={}) collection.select{|c| c.send(.keys.first) == .values.first}.first end |
#find_by_in_relationships(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 |
# File 'lib/active_mocker/model_schema.rb', line 36 def find_by_in_relationships(={}) result = nil collection.each do |item| result = item.relationships.select do |attr| attr.send(.keys.first) == .values.first end end result end |