fetcheable_on_api 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5006d8ade0d23b31a507298ca3fd128a9007f9ad
4
- data.tar.gz: d7c7e3b94a881bedcb86e31530ae7b2835e94c7c
3
+ metadata.gz: 5da599e1695d12e998a218d88038c4999f8e063a
4
+ data.tar.gz: 97677585e0c3b456f220326dd78ac708492af438
5
5
  SHA512:
6
- metadata.gz: '076778c141f6f482f38f7e7d47b9533e76ac2c2955b16c5f5fd142f4c177113a61abdc2d9757ae8846c2e7f92fdb8e58771c990ea7bf7defc9bc5f33117853c1'
7
- data.tar.gz: ceaf193da398f7feafdaae1e184282d7e92d997c278ef7ad0f55830b7ce594cc40e01edd1b3bcb69a1ab4301944cca9be51901bee5b9a618546dd1a5b10ede44
6
+ metadata.gz: b4cf30622b1a5a2d8e815e3611ec27091e299540d519233166705b91049986c81ae35dc18e68bfe61068f6693a551b22c3247c4629842f6795891e7a565f0a8b
7
+ data.tar.gz: fa4048332338e34a424d1f540d2798d789894ec7ca2fb5f95f81205dec8d174900b19cb769ab845aa402fe81eddc7b136d9fec6f8e9683d3f74f24e66132d6ff
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'fetcheable_on_api/configuration'
3
4
  require 'fetcheable_on_api/filtreable'
4
5
  require 'fetcheable_on_api/pagineable'
5
6
  require 'fetcheable_on_api/sortable'
@@ -7,6 +8,21 @@ require 'fetcheable_on_api/version'
7
8
  require 'active_support'
8
9
 
9
10
  module FetcheableOnApi
11
+ #
12
+ # Configuration
13
+ #
14
+ class << self
15
+ attr_accessor :configuration
16
+ end
17
+
18
+ def self.configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ def self.configure
23
+ yield(configuration)
24
+ end
25
+
10
26
  #
11
27
  # Supports
12
28
  #
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FetcheableOnApi
4
+ class Configuration
5
+ attr_accessor :pagination_default_size
6
+
7
+ def initialize
8
+ @pagination_default_size = 25
9
+ end
10
+ end
11
+ end
@@ -22,7 +22,11 @@ module FetcheableOnApi
22
22
  def apply_pagination(collection)
23
23
  return collection if params[:page].blank?
24
24
 
25
- limit = params[:page].fetch(:size, 25).to_i
25
+ limit = params[:page].fetch(
26
+ :size,
27
+ FetcheableOnApi.configuration.pagination_default_size
28
+ ).to_i
29
+
26
30
  offset = (params[:page].fetch(:number, 1).to_i - 1) * limit
27
31
 
28
32
  collection.limit(limit).offset(offset)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FetcheableOnApi
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.2'.freeze
5
5
  end
@@ -0,0 +1,12 @@
1
+ module FetcheableOnApi
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+ desc "Creates FetcheableOnApi initializer for your application"
6
+
7
+ def copy_initializer
8
+ template "fetcheable_on_api_initializer.rb", "config/initializers/fetcheable_on_api.rb"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ FetcheableOnApi.configure do |config|
2
+ config.pagination_default_size = 25
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fetcheable_on_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabien
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,10 +94,13 @@ files:
94
94
  - README.md
95
95
  - Rakefile
96
96
  - lib/fetcheable_on_api.rb
97
+ - lib/fetcheable_on_api/configuration.rb
97
98
  - lib/fetcheable_on_api/filtreable.rb
98
99
  - lib/fetcheable_on_api/pagineable.rb
99
100
  - lib/fetcheable_on_api/sortable.rb
100
101
  - lib/fetcheable_on_api/version.rb
102
+ - lib/generators/fetcheable_on_api/install_generator.rb
103
+ - lib/generators/templates/fetcheable_on_api_initializer.rb
101
104
  homepage: https://github.com/FabienPiette/fetcheable_on_api.git
102
105
  licenses:
103
106
  - MIT