Class: Datasource::CollectionContext
- Inherits:
-
Object
- Object
- Datasource::CollectionContext
- Defined in:
- lib/datasource/collection_context.rb
Instance Attribute Summary collapse
-
#all_models ⇒ Object
readonly
Returns the value of attribute all_models.
-
#datasource ⇒ Object
readonly
Returns the value of attribute datasource.
-
#datasource_class ⇒ Object
readonly
Returns the value of attribute datasource_class.
-
#loaded_values ⇒ Object
readonly
Returns the value of attribute loaded_values.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(scope, collection, datasource, params) ⇒ CollectionContext
constructor
A new instance of CollectionContext.
- #model_ids ⇒ Object (also: #ids)
- #models ⇒ Object
Constructor Details
#initialize(scope, collection, datasource, params) ⇒ CollectionContext
Returns a new instance of CollectionContext.
5 6 7 8 9 10 11 12 |
# File 'lib/datasource/collection_context.rb', line 5 def initialize(scope, collection, datasource, params) @scope = scope @all_models = collection @datasource = datasource @datasource_class = datasource.class @params = params @loaded_values = {} end |
Instance Attribute Details
#all_models ⇒ Object (readonly)
Returns the value of attribute all_models.
3 4 5 |
# File 'lib/datasource/collection_context.rb', line 3 def all_models @all_models end |
#datasource ⇒ Object (readonly)
Returns the value of attribute datasource.
3 4 5 |
# File 'lib/datasource/collection_context.rb', line 3 def datasource @datasource end |
#datasource_class ⇒ Object (readonly)
Returns the value of attribute datasource_class.
3 4 5 |
# File 'lib/datasource/collection_context.rb', line 3 def datasource_class @datasource_class end |
#loaded_values ⇒ Object (readonly)
Returns the value of attribute loaded_values.
3 4 5 |
# File 'lib/datasource/collection_context.rb', line 3 def loaded_values @loaded_values end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/datasource/collection_context.rb', line 3 def params @params end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
3 4 5 |
# File 'lib/datasource/collection_context.rb', line 3 def scope @scope end |
Instance Method Details
#model_ids ⇒ Object Also known as: ids
25 26 27 28 29 |
# File 'lib/datasource/collection_context.rb', line 25 def model_ids return @model_ids if @model_ids models @model_ids end |
#models ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/datasource/collection_context.rb', line 14 def models return @models if @models @model_ids = [] @models = all_models.select do |model| id = model.send(@datasource_class.primary_key) @model_ids << id id end end |