Module: ROM::Plugins::Schema::Timestamps
- Defined in:
- 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
- .apply(schema, options) ⇒ Object private
Class Method Details
.apply(schema, options) ⇒ 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.
27 28 29 30 31 32 33 34 35 |
# File 'lib/rom/plugins/schema/timestamps.rb', line 27 def self.apply(schema, ) type = .fetch(:type, Types::Time) names = .fetch(:attributes, DEFAULT_TIMESTAMPS) attributes = names.map { |name| type.(name: name, source: schema.name) } schema.attributes.concat( schema.class.attributes(attributes, schema.attr_class) ) end |