Class: Golden::Setting::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Golden::Setting::Base
- Defined in:
- lib/golden/setting/base.rb
Direct Known Subclasses
Class Method Summary collapse
-
.has_attribute?(name) ⇒ Boolean
For SimpleForm#find_attribute_column.
-
.method_missing(method, *args) ⇒ Object
For SimpleForm#find_attribute_column def type_for_attribute name; end.
- .named(name) ⇒ Object
- .select_object(fields = %w{name value form_options}) ⇒ Object
- .without_resource ⇒ Object
Methods included from FormOption
#field_type, #field_type=, #field_values, #field_values=, #form_options
Methods included from Value
Class Method Details
.has_attribute?(name) ⇒ Boolean
For SimpleForm#find_attribute_column
27 28 29 |
# File 'lib/golden/setting/base.rb', line 27 def has_attribute? name named(name).exists? end |
.method_missing(method, *args) ⇒ Object
For SimpleForm#find_attribute_column def type_for_attribute name; end
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/golden/setting/base.rb', line 34 def method_missing method, *args super method, *args rescue NoMethodError name = method.to_s if name =~ /=$/ name.gsub!('=', '') self[name] = args.first elsif name =~ /\?$/ name.gsub!('?', '') self.is_true? name else self[name] end end |
.named(name) ⇒ Object
18 19 20 |
# File 'lib/golden/setting/base.rb', line 18 def named name without_resource.where(name: name) end |
.select_object(fields = %w{name value form_options}) ⇒ Object
22 23 24 |
# File 'lib/golden/setting/base.rb', line 22 def select_object fields = %w{name value form_options} without_resource.select(fields) end |
.without_resource ⇒ Object
14 15 16 |
# File 'lib/golden/setting/base.rb', line 14 def without_resource where(resource_type: nil, resource_id: nil) end |