Module: ROM::Plugins::Schema::Timestamps
- Defined in:
- core/lib/rom/plugins/schema/timestamps.rb
Overview
A plugin for automatically adding timestamp fields to the schema definition
Defined Under Namespace
Modules: DSL
Constant Summary collapse
- DEFAULT_TIMESTAMPS =
%i[created_at updated_at].freeze
Class Method Summary collapse
Class Method Details
.apply(schema, type: Types::Time, attributes: DEFAULT_TIMESTAMPS) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'core/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.(source: schema.name), name: name ) end schema.attributes.concat( schema.class.attributes(attrs, schema.attr_class) ) end |