Sha256: 642c6951631734407afa8d804dd0ad61b72214c27e104dace8e89e3392d2d3a6

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

# @api description
# All Rails models making use of #belongs_to_anchormodel must include this mixin. Typically, it is included in `application_record.rb`.
module Anchormodel::ModelMixin
  extend ActiveSupport::Concern

  included do
    class_attribute :anchormodel_attributes, default: {}.freeze
  end

  class_methods do
    # Creates an attribute linking to an Anchormodel. The attribute should be
    # present in the DB and the column should be of type String and named the same as `attribute_name`.
    # @see Anchormodel::Util#install_methods_in_model Parameters
    def belongs_to_anchormodel(*args, **kwargs)
      Anchormodel::Util.install_methods_in_model(self, *args, **kwargs)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anchormodel-0.1.5 lib/anchormodel/model_mixin.rb
anchormodel-0.1.4 lib/anchormodel/model_mixin.rb