Module: DHS::Record::Configuration::ClassMethods
- Defined in:
- lib/dhs/concerns/record/configuration.rb
Instance Method Summary collapse
- #auto_oauth ⇒ Object
- #auto_oauth? ⇒ Boolean
- #configuration(args = nil) ⇒ Object
- #item_created_key ⇒ Object
- #item_key ⇒ Object
- #items_key ⇒ Object
- #limit_key(type = nil) ⇒ Object
- #oauth(provider = nil) ⇒ Object
-
#paginated ⇒ Object
Allows record to be configured as not paginated, as by default it’s considered paginated.
-
#pagination_key(type = nil) ⇒ Object
Key used for determine current page.
-
#pagination_strategy ⇒ Object
Strategy used for calculationg next pages and navigate pages.
- #total_key ⇒ Object
Instance Method Details
#auto_oauth ⇒ Object
27 28 29 |
# File 'lib/dhs/concerns/record/configuration.rb', line 27 def auto_oauth configuration.fetch(:auto_oauth, false) end |
#auto_oauth? ⇒ Boolean
23 24 25 |
# File 'lib/dhs/concerns/record/configuration.rb', line 23 def auto_oauth? DHS.config.auto_oauth && configuration && auto_oauth end |
#configuration(args = nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/dhs/concerns/record/configuration.rb', line 15 def configuration(args = nil) if !args.nil? @configuration = args else @configuration || {} end end |
#item_created_key ⇒ Object
48 49 50 51 52 |
# File 'lib/dhs/concerns/record/configuration.rb', line 48 def item_created_key symbolize_unless_complex( configuration.dig(:item_created_key) ) end |
#item_key ⇒ Object
36 37 38 39 40 |
# File 'lib/dhs/concerns/record/configuration.rb', line 36 def item_key symbolize_unless_complex( configuration.dig(:item_key) || :item ) end |
#items_key ⇒ Object
42 43 44 45 46 |
# File 'lib/dhs/concerns/record/configuration.rb', line 42 def items_key symbolize_unless_complex( configuration.dig(:items_key) || :items ) end |
#limit_key(type = nil) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/dhs/concerns/record/configuration.rb', line 54 def limit_key(type = nil) symbolize_unless_complex( pagination_parameter(configuration.dig(:limit_key), type) || :limit ) end |
#oauth(provider = nil) ⇒ Object
31 32 33 34 |
# File 'lib/dhs/concerns/record/configuration.rb', line 31 def oauth(provider = nil) value = provider || true configuration.present? ? configuration.merge!(auto_oauth: value) : configuration(auto_oauth: value) end |
#paginated ⇒ Object
Allows record to be configured as not paginated, as by default it’s considered paginated
84 85 86 87 |
# File 'lib/dhs/concerns/record/configuration.rb', line 84 def paginated return true if configuration.blank? configuration.fetch(:paginated, true) end |
#pagination_key(type = nil) ⇒ Object
Key used for determine current page
68 69 70 71 72 73 |
# File 'lib/dhs/concerns/record/configuration.rb', line 68 def pagination_key(type = nil) symbolize_unless_complex( pagination_parameter(configuration.dig(:pagination_key), type) || :offset ) end |
#pagination_strategy ⇒ Object
Strategy used for calculationg next pages and navigate pages
76 77 78 79 80 |
# File 'lib/dhs/concerns/record/configuration.rb', line 76 def pagination_strategy symbolize_unless_complex( configuration.dig(:pagination_strategy) || :offset ) end |
#total_key ⇒ Object
61 62 63 64 65 |
# File 'lib/dhs/concerns/record/configuration.rb', line 61 def total_key symbolize_unless_complex( configuration.dig(:total_key) || :total ) end |