Module: Bizarroids::Settings

Defined in:
lib/bizarroids/settings.rb,
lib/bizarroids/settings/engine.rb,
lib/bizarroids/settings/version.rb,
lib/bizarroids/settings/config_error.rb,
app/models/bizarroids/settings/option.rb,
app/helpers/bizarroids/settings/settings_helper.rb,
app/controllers/bizarroids/settings/options_controller.rb,
app/controllers/bizarroids/settings/application_controller.rb,
lib/bizarroids/settings/bizarroids_settings_option_uploader.rb

Defined Under Namespace

Modules: OptionsHelper, SettingsHelper Classes: ApplicationController, ConfigError, Engine, InstallGenerator, Option, OptionUploader, OptionsController

Constant Summary collapse

VALUE_TYPES =
%w(string integer float boolean text date datetime file).freeze
VERSION =
"0.1.3".freeze
@@options =
{}
@@keys =
[]
@@parent_controller =
'::ApplicationController'
@@use_cancancan =
true
@@files_storage_dir =
'system/settings'

Class Method Summary collapse

Class Method Details

.get(key) ⇒ Object Also known as: []

Raises:

  • (ActiveRecord::RecordNotFound)


20
21
22
23
# File 'lib/bizarroids/settings.rb', line 20

def self.get key
  raise ActiveRecord::RecordNotFound.new("Option ':#{key}' not defined") unless key.in? keys
  Option.find_by!(key: key).try :get_value
end

.set(key, value) ⇒ Object Also known as: []=

Raises:

  • (ActiveRecord::RecordNotFound)


25
26
27
28
# File 'lib/bizarroids/settings.rb', line 25

def self.set key, value
  raise ActiveRecord::RecordNotFound.new("Option ':#{key}' not defined") unless key.in? keys
  Option.find_by!(key: key).set_value value
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



50
51
52
# File 'lib/bizarroids/settings.rb', line 50

def self.setup
  yield self
end

.table_name_prefixObject

name prefix for ActiveRecord



14
15
16
# File 'lib/bizarroids/settings.rb', line 14

def self.table_name_prefix
  'bizarroids_settings_'
end