Sha256: 3ccbf0b1452063f9012c07bab25c6c4dc4154468f7eead86517f9c5e7777301c

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

module StateObjects
  
  class Error < RuntimeError
  end
  
  class Base

    def initialize(model)
      @model = model               
    end

    def self.state_object_values(*opts)  # :nodoc:          
      unless opts.size == 3
        raise StateObjects::Error.new @model.to_s + "#state_object_values Must have 3 arguments: symbol, db_value, label.  For Example: state_object_values :red,'R','Dont Walk'"
      end
      
      class_eval <<-EOF
        def self.symbol
          '#{opts[0]}'.to_sym
        end
        def self.db_value
          '#{opts[1]}'
        end
        def self.label
          '#{opts[2]}'
        end
      EOF
    end

    protected 
      def model
        @model
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
state_objects-0.9.2 lib/state_objects/base.rb