Module: ActiveRecord::KSUID
- Defined in:
- lib/active_record/ksuid.rb,
lib/active_record/ksuid/type.rb,
lib/active_record/ksuid/railtie.rb,
lib/active_record/ksuid/version.rb,
lib/active_record/ksuid/binary_type.rb,
lib/active_record/ksuid/prefixed_type.rb,
lib/active_record/ksuid/table_definition.rb
Overview
Enables an Active Record model to have a KSUID attribute
Defined Under Namespace
Modules: TableDefinition Classes: BinaryType, PrefixedType, Railtie, Type
Constant Summary collapse
- VERSION =
The version of the activerecord-ksuid gem
'1.0.0'
Class Method Summary collapse
-
.[](field, auto_gen: true, created_at: false, binary: false, prefix: nil) ⇒ Module
Builds a module to include into the model.
Class Method Details
.[](field, auto_gen: true, created_at: false, binary: false, prefix: nil) ⇒ Module
Builds a module to include into the model
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/active_record/ksuid.rb', line 41 def self.[](field, auto_gen: true, created_at: false, binary: false, prefix: nil) raise ArgumentError, 'cannot include a prefix on a binary KSUID' if binary && prefix Module.new.tap do |mod| if prefix define_prefixed_attribute(field, mod, auto_gen, prefix) else define_attribute(field, mod, auto_gen, binary) end define_created_at(field, mod) if created_at end end |