Class: PersistentEnum::EnumSpec
- Inherits:
-
Struct
- Object
- Struct
- PersistentEnum::EnumSpec
- Defined in:
- lib/persistent_enum.rb
Overview
Closes over the arguments to ‘acts_as_enum` so that it can be reloaded.
Defined Under Namespace
Classes: ConstantEvaluator
Instance Attribute Summary collapse
-
#constant_block ⇒ Object
Returns the value of attribute constant_block.
-
#constant_hash ⇒ Object
Returns the value of attribute constant_hash.
-
#name_attr ⇒ Object
Returns the value of attribute name_attr.
-
#sql_enum_type ⇒ Object
Returns the value of attribute sql_enum_type.
Instance Method Summary collapse
-
#initialize(constant_block, constant_hash, name_attr, sql_enum_type) ⇒ EnumSpec
constructor
A new instance of EnumSpec.
- #required_members ⇒ Object
Constructor Details
#initialize(constant_block, constant_hash, name_attr, sql_enum_type) ⇒ EnumSpec
63 64 65 66 67 68 69 70 |
# File 'lib/persistent_enum.rb', line 63 def initialize(constant_block, constant_hash, name_attr, sql_enum_type) unless constant_block.nil? ^ constant_hash.nil? raise ArgumentError.new('Constants must be provided by exactly one of hash argument or builder block') end super(constant_block, constant_hash, name_attr.to_s, sql_enum_type) freeze end |
Instance Attribute Details
#constant_block ⇒ Object
Returns the value of attribute constant_block
62 63 64 |
# File 'lib/persistent_enum.rb', line 62 def constant_block @constant_block end |
#constant_hash ⇒ Object
Returns the value of attribute constant_hash
62 63 64 |
# File 'lib/persistent_enum.rb', line 62 def constant_hash @constant_hash end |
#name_attr ⇒ Object
Returns the value of attribute name_attr
62 63 64 |
# File 'lib/persistent_enum.rb', line 62 def name_attr @name_attr end |
#sql_enum_type ⇒ Object
Returns the value of attribute sql_enum_type
62 63 64 |
# File 'lib/persistent_enum.rb', line 62 def sql_enum_type @sql_enum_type end |
Instance Method Details
#required_members ⇒ Object
72 73 74 |
# File 'lib/persistent_enum.rb', line 72 def required_members constant_hash || ConstantEvaluator.new.evaluate(&constant_block) end |