Class: ForestLiana::HasManyGetter
- Inherits:
-
BaseGetter
- Object
- BaseGetter
- ForestLiana::HasManyGetter
- Defined in:
- app/services/forest_liana/has_many_getter.rb
Constant Summary collapse
- SUPPORTED_ASSOCIATION_MACROS =
[:belongs_to, :has_one, :has_and_belongs_to_many].freeze
Instance Attribute Summary collapse
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#records_count ⇒ Object
readonly
Returns the value of attribute records_count.
-
#search_query_builder ⇒ Object
readonly
Returns the value of attribute search_query_builder.
Instance Method Summary collapse
- #count ⇒ Object
-
#initialize(resource, association, params, forest_user) ⇒ HasManyGetter
constructor
A new instance of HasManyGetter.
- #perform ⇒ Object
- #query_for_batch ⇒ Object
- #records ⇒ Object
Methods inherited from BaseGetter
#get_collection, #get_resource, #includes_for_serialization
Constructor Details
#initialize(resource, association, params, forest_user) ⇒ HasManyGetter
Returns a new instance of HasManyGetter.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/forest_liana/has_many_getter.rb', line 9 def initialize(resource, association, params, forest_user) @resource = resource @association = association @params = params @collection_name = ForestLiana.name_for(model_association) @field_names_requested = field_names_requested @collection = get_collection(@collection_name) compute_includes() includes_symbols = @includes.map { |include| include.to_sym } @search_query_builder = SearchQueryBuilder.new(@params, includes_symbols, @collection, forest_user) prepare_query() end |
Instance Attribute Details
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
4 5 6 |
# File 'app/services/forest_liana/has_many_getter.rb', line 4 def includes @includes end |
#records_count ⇒ Object (readonly)
Returns the value of attribute records_count.
5 6 7 |
# File 'app/services/forest_liana/has_many_getter.rb', line 5 def records_count @records_count end |
#search_query_builder ⇒ Object (readonly)
Returns the value of attribute search_query_builder.
3 4 5 |
# File 'app/services/forest_liana/has_many_getter.rb', line 3 def search_query_builder @search_query_builder end |
Instance Method Details
#count ⇒ Object
27 28 29 |
# File 'app/services/forest_liana/has_many_getter.rb', line 27 def count @records_count = @records.count end |
#perform ⇒ Object
23 24 25 |
# File 'app/services/forest_liana/has_many_getter.rb', line 23 def perform @records end |
#query_for_batch ⇒ Object
31 32 33 |
# File 'app/services/forest_liana/has_many_getter.rb', line 31 def query_for_batch @records end |
#records ⇒ Object
35 36 37 |
# File 'app/services/forest_liana/has_many_getter.rb', line 35 def records @records.limit(limit).offset(offset) end |