Class: Settr
- Inherits:
-
Object
show all
- Defined in:
- lib/settr.rb,
lib/settr/engine.rb,
lib/settr/version.rb,
app/helpers/settr/settings_helper.rb,
lib/generators/settr/install_generator.rb
Defined Under Namespace
Modules: Generators, SettingsHelper
Classes: ApplicationController, Engine, SettingsController
Constant Summary
collapse
- VERSION =
"0.1.2"
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
36
37
38
39
40
|
# File 'lib/settr.rb', line 36
def method_missing(sym, *args, &block)
s = sym.to_s.end_with?("?") ? sym.to_s[0..-2] : nil
@str = @str ? "#{@str}.#{s || sym}" : (s || sym.to_s)
s ? get_val.present? : self
end
|
Class Method Details
.method_missing(*args) ⇒ Object
32
33
34
|
# File 'lib/settr.rb', line 32
def self.method_missing(*args)
Settr.new.send(*args)
end
|
.setup {|_self| ... } ⇒ Object
default way to setup settr
28
29
30
|
# File 'lib/settr.rb', line 28
def self.setup
yield self
end
|
Instance Method Details
#get_val ⇒ Object
42
43
44
45
46
|
# File 'lib/settr.rb', line 42
def get_val()
setting = SettrSetting.where(key: @str).first
return unless setting
setting.val
end
|
#to_f ⇒ Object
58
59
60
|
# File 'lib/settr.rb', line 58
def to_f()
get_val.to_f
end
|
#to_i ⇒ Object
Also known as:
to_int
53
54
55
|
# File 'lib/settr.rb', line 53
def to_i()
get_val.to_i
end
|
#to_s ⇒ Object
Also known as:
to_str, inspect
48
49
50
|
# File 'lib/settr.rb', line 48
def to_s()
get_val.to_s
end
|