Sha256: bc18de0f80fd797aea4e91ce6b779677ec84296ce9ed60a4535a25d6d754639b

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module AxleAttributes
  module Model
    extend ActiveSupport::Concern

    included do
      unless include?(ElasticRecord::Model)
        include ElasticRecord::Model
      end

      include AxleAttributes::HasAttributes
      self.has_attribute_definition_class = '::AxleAttributes::ParentDefinition'
      add_core_axle_attributes! unless self.name.demodulize == 'Base'

      include AxleAttributes::Provided
      include AxleAttributes::Segmented
      include AxleAttributes::Serializations
      include AxleAttributes::Versioned
      include AxleAttributes::Validations
    end

    module ClassMethods
      def inherited(child)
        super
        child.add_core_axle_attributes!
      end

      def add_core_axle_attributes!
        has_attribute(:created_at, type: :time, index: true, editable: false) unless attributes['created_at']
        has_attribute(:updated_at, type: :time, index: true, editable: false) unless attributes['updated_at']
        has_attribute(:segment_id, type: :integer, index: true, editable: false) unless attributes['segment_id']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axle_attributes-1.13.2 lib/axle_attributes/model.rb