Module: RestPack::Service
- Defined in:
- lib/restpack-resource/service.rb
Instance Method Summary collapse
- #paged_resource(klass, params, options = {}) ⇒ Object
- #single_resource(klass, params, options = {}) ⇒ Object
Instance Method Details
#paged_resource(klass, params, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/restpack-resource/service.rb', line 6 def paged_resource(klass, params, = {}) [:page] ||= params['page'].to_i if params['page'] [:includes] ||= extract_includes_from_params(params) unless params['includes'].nil? [:sort_by] ||= params['sort_by'].to_sym if params['sort_by'] [:sort_direction] ||= params['sort_direction'].to_sym if params['sort_direction'] filters = extract_filters_from_params(klass, params) [:filters] ||= filters unless filters.empty? klass.paged_resource() end |
#single_resource(klass, params, options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/restpack-resource/service.rb', line 18 def single_resource(klass, params, = {}) [:id] ||= params['id'] if params['id'] [:includes] ||= extract_includes_from_params(params) unless params['includes'].nil? klass.single_resource() end |