Module: ActiveRecord::VirtualEnumerations
- Defined in:
- lib/active_record/virtual_enumerations.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Config
Class Method Summary collapse
Class Method Details
.define {|config| ... } ⇒ Object
7 8 9 10 11 12 |
# File 'lib/active_record/virtual_enumerations.rb', line 7 def define raise ArgumentError, "#{self.name}: must pass a block to define()" unless block_given? config = ActiveRecord::VirtualEnumerations::Config.new yield config @config = config # we only overwrite config if no exceptions were thrown end |
.synthesize_if_defined(const) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_record/virtual_enumerations.rb', line 14 def synthesize_if_defined(const) = @config[const] return nil unless class_def = " class \#{const} < \#{options[:extends]}\n acts_as_enumerated :conditions => \#{options[:conditions].inspect},\n :order => \#{options[:order].inspect},\n :on_lookup_failure => \#{options[:on_lookup_failure].inspect}\n set_table_name(\#{options[:table_name].inspect}) unless \#{options[:table_name].nil?}\n end\n end_eval\n eval(class_def, TOPLEVEL_BINDING)\n rval = const_get(const)\n if options[:post_synth_block]\n rval.class_eval(&options[:post_synth_block])\n end\n return rval\nend\n" |