Module: ActiveEnum

Defined in:
lib/active_enum.rb,
lib/active_enum/base.rb,
lib/active_enum/railtie.rb,
lib/active_enum/version.rb,
lib/active_enum/extensions.rb,
lib/active_enum/acts_as_enum.rb,
lib/active_enum/storage/i18n_store.rb,
lib/active_enum/storage/memory_store.rb,
lib/active_enum/storage/abstract_store.rb,
lib/active_enum/form_helpers/simple_form.rb,
lib/generators/active_enum/locale_generator.rb,
lib/generators/active_enum/install_generator.rb

Defined Under Namespace

Modules: ActsAsEnum, Extensions, FormHelpers, Generators, Storage Classes: Base, DuplicateValue, EnumDefinitions, EnumNotFound, InvalidValue, NotFound, Railtie

Constant Summary collapse

VERSION =
'1.2.1'
@@enum_classes =
[]
@@use_name_as_value =
false
@@raise_on_not_found =
false
@@storage =
:memory
@@storage_options =
{}
@@default_select_value_transform =
proc { |value| [ value[1].html_safe, value[0] ] }
@@default_select_group_transform =
proc { |group| group&.html_safe }
@@extend_classes =
[]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configObject



43
44
45
# File 'lib/active_enum.rb', line 43

def self.config
  self
end

.define(&block) ⇒ Object

Define enums in bulk



57
58
59
60
# File 'lib/active_enum.rb', line 57

def self.define(&block)
  raise "Define requires block" unless block_given?
  EnumDefinitions.new.instance_eval(&block)
end

.setup {|config| ... } ⇒ Object

Setup method for plugin configuration

Yields:



38
39
40
41
# File 'lib/active_enum.rb', line 38

def self.setup
  yield config
  extend_classes!
end

.storage_classObject



62
63
64
# File 'lib/active_enum.rb', line 62

def self.storage_class
  @@storage_class ||= "ActiveEnum::Storage::#{storage.to_s.classify}Store".constantize
end

Instance Method Details

#storage=(*args) ⇒ Object



29
30
31
32
# File 'lib/active_enum.rb', line 29

def storage=(*args)
  @@storage_options = args.extract_options!
  @@storage = args.first
end