Sha256: e2e976e345dc27608a23a6fc3027f5ce77e48411ac8234f58aecb708235d9070

Contents?: true

Size: 1 KB

Versions: 15

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Decidim
  module TermCustomizer
    class Constraint < TermCustomizer::ApplicationRecord
      self.table_name = "decidim_term_customizer_constraints"

      belongs_to :organization, foreign_key: :decidim_organization_id, class_name: "Decidim::Organization"
      belongs_to :translation_set, class_name: "Decidim::TermCustomizer::TranslationSet", foreign_key: "translation_set_id"
      belongs_to :subject, optional: true, polymorphic: true
      has_many :translations, through: :translation_set

      def component
        subject if subject.is_a?(Decidim::Component)
      end

      def space
        return component.participatory_space if component

        subject
      end

      def manifest
        space_class = space ? space.class.name : subject_type

        Decidim.participatory_space_manifests.find do |manifest|
          manifest.model_class_name == space_class
        end
      end

      def manifest_name
        manifest.try(:name)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
decidim-term_customizer-0.23.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.22.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.21.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.20.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.19.1 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.19.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.18.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.17.1 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.17.0 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.16.6 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.16.5 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.16.3 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.16.2 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.16.1 app/models/decidim/term_customizer/constraint.rb
decidim-term_customizer-0.16.0 app/models/decidim/term_customizer/constraint.rb