Class: Gaku::Preset

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gaku/preset.rb

Class Method Summary collapse

Class Method Details

.activeObject



35
36
37
# File 'app/models/gaku/preset.rb', line 35

def self.active
  where(active: true).first
end

.address(key) ⇒ Object



43
44
45
# File 'app/models/gaku/preset.rb', line 43

def self.address(key)
  active.address[key.to_s] unless active.nil?
end

.countryObject



55
56
57
58
59
60
61
# File 'app/models/gaku/preset.rb', line 55

def self.country
  if active
    Country.find(active.address['country'])
  else
    Country.first
  end
end

.defaultObject



31
32
33
# File 'app/models/gaku/preset.rb', line 31

def self.default
  where(default: true).first
end

.per_page(key) ⇒ Object



39
40
41
# File 'app/models/gaku/preset.rb', line 39

def self.per_page(key)
  active.pagination[key.to_s].to_i unless active.nil?
end

.stateObject



47
48
49
50
51
52
53
# File 'app/models/gaku/preset.rb', line 47

def self.state
  if active
    State.find(active.address['state'])
  else
    State.first
  end
end