Sha256: 888356322affcd10b5441c913cec3e5dd314003521907ddd306ce657745bf16f

Contents?: true

Size: 496 Bytes

Versions: 3

Compression:

Stored size: 496 Bytes

Contents

# frozen_string_literal: true

module Vimo
  class Entity < ApplicationRecord
    include SystemName

    validates :name, presence: true

    has_system_name uniqueness_scope: [:owner_type, :owner_id]

    has_many :fields
    has_many :items
    belongs_to :owner, polymorphic: true, required: false

    accepts_nested_attributes_for :fields,
      reject_if: :all_blank,
      allow_destroy: true

    def as_json(options = nil)
      super(options.merge(include: :fields))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vimo-0.1.3 app/models/vimo/entity.rb
vimo-0.1.1 app/models/vimo/entity.rb
vimo-0.1.0 app/models/vimo/entity.rb