Class: SettingConverter

Inherits:
Object
  • Object
show all
Defined in:
app/models/site_setting.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ SettingConverter

Returns a new instance of SettingConverter.



80
81
82
# File 'app/models/site_setting.rb', line 80

def initialize(value)
  @value = value
end

Instance Method Details

#as_booleanObject



100
101
102
# File 'app/models/site_setting.rb', line 100

def as_boolean
  ActiveModel::Type::Boolean.new.cast(@value)
end

#as_floatObject



96
97
98
# File 'app/models/site_setting.rb', line 96

def as_float
  @value&.to_f
end

#as_integerObject



92
93
94
# File 'app/models/site_setting.rb', line 92

def as_integer
  @value&.to_i
end

#as_jsonObject



104
105
106
# File 'app/models/site_setting.rb', line 104

def as_json
  JSON.parse(@value)
end

#as_stringObject



84
85
86
# File 'app/models/site_setting.rb', line 84

def as_string
  @value&.to_s
end

#as_textObject



88
89
90
# File 'app/models/site_setting.rb', line 88

def as_text
  @value&.to_s
end