module PostJson::SettingsMethods::ClassMethods
Public Instance Methods
create_dynamic_index_milliseconds_threshold()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 119 def create_dynamic_index_milliseconds_threshold read_settings_attribute('create_dynamic_index_milliseconds_threshold') end
create_dynamic_index_milliseconds_threshold=(millisecs)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 123 def create_dynamic_index_milliseconds_threshold=(millisecs) write_settings_attribute('create_dynamic_index_milliseconds_threshold', millisecs) end
created_at_attribute_name()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 79 def created_at_attribute_name read_settings_attribute('created_at_attribute_name') end
created_at_attribute_name=(attribute_name)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 83 def created_at_attribute_name=(attribute_name) write_settings_attribute('created_at_attribute_name', attribute_name) end
destroy!()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 37 def destroy! if persisted? settings.destroy reload_settings! else settings end end
include_version_number()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 95 def include_version_number read_settings_attribute('include_version_number') end
include_version_number=(value)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 99 def include_version_number=(value) write_settings_attribute('include_version_number', value) end
meta()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 60 def meta HashWithIndifferentAccess.new(read_settings_attribute('meta')) end
meta=(hash)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 64 def meta=(hash) write_settings_attribute('meta', HashWithIndifferentAccess.new(hash)) end
method_missing(method_symbol, *args, &block)
click to toggle source
Calls superclass method
# File lib/post_json/concerns/settings_methods.rb, line 127 def method_missing(method_symbol, *args, &block) method = method_symbol.to_s if method.start_with?("meta_") && method.end_with?("=") && args.length == 1 attribute_name = method[5..-2] self.meta = self.meta.merge(attribute_name => args[0]) args[0] elsif method.start_with?("meta_") && args.length == 0 attribute_name = method[5..-1] self.meta[attribute_name] else super end end
new?()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 24 def new? settings.new_record? end
persisted?()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 28 def persisted? settings.persisted? end
persisted_settings()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 10 def persisted_settings if settings.new_record? existing = ModelSettings.by_collection(collection_name).first if existing updates = settings.changes.inject({}) {|result, (k,v)| result[k] = v[1]; result} existing.update_attributes(updates) @settings = existing else settings.save! end end settings end
read_settings_attribute(attribute_name)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 46 def read_settings_attribute(attribute_name) attribute_name = attribute_name.to_s settings[attribute_name] end
reload_settings!()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 32 def reload_settings! @settings = nil settings end
settings()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 6 def settings @settings ||= ModelSettings.by_collection(collection_name).first_or_initialize(collection_name: collection_name) end
updated_at_attribute_name()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 87 def updated_at_attribute_name read_settings_attribute('updated_at_attribute_name') end
updated_at_attribute_name=(attribute_name)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 91 def updated_at_attribute_name=(attribute_name) write_settings_attribute('updated_at_attribute_name', attribute_name) end
use_dynamic_index()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 111 def use_dynamic_index read_settings_attribute('use_dynamic_index') end
use_dynamic_index=(value)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 115 def use_dynamic_index=(value) write_settings_attribute('use_dynamic_index', value) end
use_timestamps()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 68 def use_timestamps read_settings_attribute('use_timestamps') end
Also aliased as: record_timestamps
use_timestamps=(value)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 72 def use_timestamps=(value) write_settings_attribute('use_timestamps', value) end
Also aliased as: record_timestamps=
version_attribute_name()
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 103 def version_attribute_name read_settings_attribute('version_attribute_name') end
version_attribute_name=(attribute_name)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 107 def version_attribute_name=(attribute_name) write_settings_attribute('version_attribute_name', attribute_name) end
write_settings_attribute(attribute_name, value)
click to toggle source
# File lib/post_json/concerns/settings_methods.rb, line 51 def write_settings_attribute(attribute_name, value) attribute_name = attribute_name.to_s if settings[attribute_name] != value settings[attribute_name] = value settings.save! end value end