Class: Graphiti::Util::RemoteParams
- Defined in:
- lib/graphiti/util/remote_params.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(resource, query, foreign_key) ⇒ RemoteParams
constructor
A new instance of RemoteParams.
Constructor Details
#initialize(resource, query, foreign_key) ⇒ RemoteParams
Returns a new instance of RemoteParams.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/graphiti/util/remote_params.rb', line 9 def initialize(resource, query, foreign_key) @resource = resource @query = query @foreign_key = foreign_key @sorts = [] @filters = {} @fields = {} @extra_fields = {} @pagination = {} @params = {} end |
Class Method Details
.generate(resource, query, foreign_key) ⇒ Object
5 6 7 |
# File 'lib/graphiti/util/remote_params.rb', line 5 def self.generate(resource, query, foreign_key) new(resource, query, foreign_key).generate end |
Instance Method Details
#generate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/graphiti/util/remote_params.rb', line 21 def generate if (include_hash = @query.include_hash.presence) @params[:include] = trim_sideloads(include_hash) end collect_params(@query, @resource) @params[:sort] = @sorts.join(",") if @sorts.present? @params[:filter] = @filters if @filters.present? @params[:page] = @pagination if @pagination.present? @params[:fields] = @fields if @fields.present? @params[:extra_fields] = @extra_fields if @extra_fields.present? @params[:stats] = @stats if @stats.present? @params end |