Module: LHS::Record::Configuration::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#configuration(args) ⇒ Object


15
16
17
# File 'lib/lhs/concerns/record/configuration.rb', line 15

def configuration(args)
  @configuration = args.freeze || {}
end

#item_created_keyObject


31
32
33
34
35
# File 'lib/lhs/concerns/record/configuration.rb', line 31

def item_created_key
  symbolize_unless_complex(
    @configuration.try(:[], :item_created_key)
  )
end

#item_keyObject


19
20
21
22
23
# File 'lib/lhs/concerns/record/configuration.rb', line 19

def item_key
  symbolize_unless_complex(
    @configuration.try(:[], :item_key) || :item
  )
end

#items_keyObject


25
26
27
28
29
# File 'lib/lhs/concerns/record/configuration.rb', line 25

def items_key
  symbolize_unless_complex(
    @configuration.try(:[], :items_key) || :items
  )
end

#limit_key(type = nil) ⇒ Object


37
38
39
40
41
42
# File 'lib/lhs/concerns/record/configuration.rb', line 37

def limit_key(type = nil)
  symbolize_unless_complex(
    pagination_parameter(@configuration.try(:[], :limit_key), type) ||
    :limit
  )
end

#paginatedObject

Allows record to be configured as not paginated, as by default it's considered paginated


67
68
69
70
# File 'lib/lhs/concerns/record/configuration.rb', line 67

def paginated
  return true if @configuration.blank?
  @configuration.fetch(:paginated, true)
end

#pagination_key(type = nil) ⇒ Object

Key used for determine current page


51
52
53
54
55
56
# File 'lib/lhs/concerns/record/configuration.rb', line 51

def pagination_key(type = nil)
  symbolize_unless_complex(
    pagination_parameter(@configuration.try(:[], :pagination_key), type) ||
    :offset
  )
end

#pagination_strategyObject

Strategy used for calculationg next pages and navigate pages


59
60
61
62
63
# File 'lib/lhs/concerns/record/configuration.rb', line 59

def pagination_strategy
  symbolize_unless_complex(
    @configuration.try(:[], :pagination_strategy) || :offset
  )
end

#total_keyObject


44
45
46
47
48
# File 'lib/lhs/concerns/record/configuration.rb', line 44

def total_key
  symbolize_unless_complex(
    @configuration.try(:[], :total_key) || :total
  )
end