module ROM::Plugins::Schema::Timestamps
A plugin for automatically adding timestamp fields to the schema definition
@example
schema do use :timestamps end # using non-default names schema do use :timestamps, attributes: %i(created_on updated_on) end # using other types schema do use :timestamps, type: Types::Date end
@api public
Constants
- DEFAULT_TIMESTAMPS
Public Class Methods
apply(schema, type: Types::Time, attributes: DEFAULT_TIMESTAMPS)
click to toggle source
@api private
# File lib/rom/plugins/schema/timestamps.rb, line 29 def self.apply(schema, type: Types::Time, attributes: DEFAULT_TIMESTAMPS) attrs = attributes.map do |name| ROM::Schema.build_attribute_info( type.meta(source: schema.name), name: name ) end schema.attributes.concat( schema.class.attributes(attrs, schema.attr_class) ) end