Module: SimpleEnum

Defined in:
lib/simple_enum.rb,
lib/simple_enum/enum.rb,
lib/simple_enum/hasher.rb,
lib/simple_enum/mongoid.rb,
lib/simple_enum/railtie.rb,
lib/simple_enum/version.rb,
lib/simple_enum/accessors.rb,
lib/simple_enum/attribute.rb,
lib/simple_enum/translation.rb,
lib/simple_enum/view_helpers.rb,
lib/simple_enum/accessors/accessor.rb,
lib/simple_enum/accessors/whiny_accessor.rb,
lib/simple_enum/accessors/ignore_accessor.rb

Overview

Base module which gets included in ActiveRecord::Base. See documentation of SimpleEnum::ClassMethods for more details.

Defined Under Namespace

Modules: Accessors, Attribute, Hasher, Mongoid, Translation, ViewHelpers Classes: Enum, Railtie

Constant Summary collapse

VERSION =

The current ‘SimpleEnum` version.

"2.3.2"
@@with =
[:attribute, :dirty, :scope]
@@accessor =
:default
@@builder =
:default
@@suffix =
"_cd"
@@field =
{}
@@pluralize_scopes =
true

Class Method Summary collapse

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (SimpleEnum)

    the object that the method was called on



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

def self.configure
  yield(self)
end

.register_accessor(key, clazz) ⇒ Object

Public: Extension method to register a custom accessor.

key - The Symbol of the accessor key, e.g. ‘:bitwise` clazz - The Class with the accessor implementation

Returns nothing



25
26
27
# File 'lib/simple_enum/accessors.rb', line 25

def self.register_accessor(key, clazz)
  Accessors::ACCESSORS[key] = clazz
end

.register_generator(name, mod) ⇒ Object

Public: Register a generator method and add module as part of SimpleEnum::Attribute. The generator method is called after all default generators have been created, this allows to override/change existing methods.

name - The Symbol with the name of the extension mod - The Module implementing ‘generate_enum_name_extension_for` method

Returns nothing



105
106
107
108
# File 'lib/simple_enum/attribute.rb', line 105

def self.register_generator(name, mod)
  Attribute.send :include, mod
  Attribute::EXTENSIONS << name.to_s
end