Sha256: 0a55fa8f7514e6727d6513bf28b3865164f7a7613cad47f9c2393721a1d5647b

Contents?: true

Size: 556 Bytes

Versions: 2

Compression:

Stored size: 556 Bytes

Contents

require 'uuidtools'

class RFlow
  class Configuration
    # Mixin for any {ConfigurationItem} that has a UUID key.
    # Sets +primary_key+ column to be +uuid+ and initializes the
    # UUID on creation.
    # @!visibility private
    module UUIDKeyed
      # @!visibility private
      def self.included(base)
        base.class_eval do
          self.primary_key = 'uuid'
          before_create :generate_uuid

          def generate_uuid
            self.uuid = UUIDTools::UUID.random_create.to_s
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rflow-1.3.2 lib/rflow/configuration/uuid_keyed.rb
rflow-1.3.1 lib/rflow/configuration/uuid_keyed.rb