Sha256: 33f0fc5aba65caaf6b8f4a8eb01fe80b25590af26e324932a033e7f43f3be69d

Contents?: true

Size: 499 Bytes

Versions: 2

Compression:

Stored size: 499 Bytes

Contents

require 'stateful_enum/machine'

module StatefulEnum
  module ActiveRecordEnumExtension
    #   enum status: {unassigned: 0, assigned: 1, resolved: 2, closed: 3} do
    #     event :assign do
    #       transition :unassigned => :assigned
    #     end
    #   end
    def enum(definitions, &block)
      enum = super definitions

      if block
        definitions.each_key do |column|
          StatefulEnum::Machine.new self, column, enum[column], &block
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stateful_enum-0.2.0 lib/stateful_enum/active_record_extension.rb
stateful_enum-0.1.0 lib/stateful_enum/active_record_extension.rb