Sha256: 1f2ab5f1996ee3394a1191c748fa61a26fa18fe0d1d12121f430325ce82a6ccc

Contents?: true

Size: 719 Bytes

Versions: 17

Compression:

Stored size: 719 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"
      delegate :organization, to: :component, allow_nil: true
      delegate :participatory_space, to: :component, allow_nil: true
    end

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
decidim-core-0.15.2 lib/decidim/has_component.rb
decidim-core-0.15.1 lib/decidim/has_component.rb
decidim-core-0.15.0 lib/decidim/has_component.rb
decidim-core-0.14.4 lib/decidim/has_component.rb
decidim-core-0.14.3 lib/decidim/has_component.rb
decidim-core-0.14.2 lib/decidim/has_component.rb
decidim-core-0.14.1 lib/decidim/has_component.rb
decidim-core-0.13.1 lib/decidim/has_component.rb
decidim-core-0.12.2 lib/decidim/has_component.rb
decidim-core-0.13.0 lib/decidim/has_component.rb
decidim-core-0.12.1 lib/decidim/has_component.rb
decidim-core-0.13.0.pre1 lib/decidim/has_component.rb
decidim-core-0.12.0 lib/decidim/has_component.rb
decidim-core-0.11.2 lib/decidim/has_component.rb
decidim-core-0.12.0.pre lib/decidim/has_component.rb
decidim-core-0.11.1 lib/decidim/has_component.rb
decidim-core-0.11.0.pre1 lib/decidim/has_component.rb