Sha256: a2c71931c018b657aa90f8b329df044febeb504a3fe9404e226c859dc7b51273

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

require_relative "model/access"

module Solid::Model
  extend ::ActiveSupport::Concern

  included do
    include ::ActiveModel.const_defined?(:Api, false) ? ::ActiveModel::Api : ::ActiveModel::Model
    include ::ActiveModel.const_defined?(:Access, false) ? ::ActiveModel::Access : ::Solid::Model::Access

    include ::ActiveModel::Attributes
    include ::ActiveModel::Dirty
    include ::ActiveModel::Validations::Callbacks
  end

  module ClassMethods
    def [](...)
      new(...)
    end

    def inherited(subclass)
      subclass.include(::Solid::Model)
    end
  end

  def inspect
    "#<#{self.class.name} #{attributes.map { |k, v| "#{k}=#{v.inspect}" }.join(" ")}>"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solid-process-0.3.0 lib/solid/model.rb
solid-process-0.2.0 lib/solid/model.rb