Module: DHS::Record::Configuration::ClassMethods

Defined in:
lib/dhs/concerns/record/configuration.rb

Instance Method Summary collapse

Instance Method Details

#auto_oauthObject



27
28
29
# File 'lib/dhs/concerns/record/configuration.rb', line 27

def auto_oauth
  configuration.fetch(:auto_oauth, false)
end

#auto_oauth?Boolean

Returns:

  • (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_keyObject



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_keyObject



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_keyObject



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

#paginatedObject

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_strategyObject

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_keyObject



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