Sha256: 22646aadcbc3ea89943c026620e4ff84a2cd8f267106ae9230767aebffc1452e

Contents?: true

Size: 881 Bytes

Versions: 39

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"
require "decidim/component_validator"

module Decidim
  # A concern with the components needed when you want a model to have a component.
  module HasComponent
    extend ActiveSupport::Concern

    included do
      belongs_to :component, foreign_key: "decidim_component_id", class_name: "Decidim::Component", touch: true
      delegate :organization, to: :component, allow_nil: true
      delegate :participatory_space, :can_participate_in_space?, to: :component, allow_nil: true

      alias_method :can_participate?, :can_participate_in_space?
    end

    class_methods do
      def belong_to_component?
        true
      end

      def component_manifest_name(manifest_name)
        validates :component, component: { manifest: manifest_name || name.demodulize.pluralize.downcase }
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
decidim-core-0.29.1 lib/decidim/has_component.rb
decidim-core-0.28.4 lib/decidim/has_component.rb
decidim-core-0.27.9 lib/decidim/has_component.rb
decidim-core-0.29.0 lib/decidim/has_component.rb
decidim-core-0.28.3 lib/decidim/has_component.rb
decidim-core-0.27.8 lib/decidim/has_component.rb
decidim-core-0.29.0.rc4 lib/decidim/has_component.rb
decidim-core-0.29.0.rc3 lib/decidim/has_component.rb
decidim-core-0.29.0.rc2 lib/decidim/has_component.rb
decidim-core-0.29.0.rc1 lib/decidim/has_component.rb
decidim-core-0.28.2 lib/decidim/has_component.rb
decidim-core-0.27.7 lib/decidim/has_component.rb
decidim-core-0.28.1 lib/decidim/has_component.rb
decidim-core-0.27.6 lib/decidim/has_component.rb
decidim-core-0.26.10 lib/decidim/has_component.rb
decidim-core-0.26.9 lib/decidim/has_component.rb
decidim-core-0.28.0 lib/decidim/has_component.rb
decidim-core-0.27.5 lib/decidim/has_component.rb
decidim-core-0.28.0.rc5 lib/decidim/has_component.rb
decidim-core-0.28.0.rc4 lib/decidim/has_component.rb