Sha256: b6631ddc86f52228ff711d2fd1d38be4132066ba2582a57b3773474b27fe8f1e

Contents?: true

Size: 615 Bytes

Versions: 13

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"
require "decidim/feature_validator"

module Decidim
  # A concern with the features needed when you want a model to have a feature.
  module HasFeature
    extend ActiveSupport::Concern

    included do
      belongs_to :feature, foreign_key: "decidim_feature_id", class_name: "Decidim::Feature"
      has_one :organization, through: :feature
    end

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

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
decidim-core-0.5.1 lib/decidim/has_feature.rb
decidim-0.5.1 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.5.0 lib/decidim/has_feature.rb
decidim-0.5.0 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.4.4 lib/decidim/has_feature.rb
decidim-core-0.4.2 lib/decidim/has_feature.rb
decidim-core-0.4.1 lib/decidim/has_feature.rb
decidim-core-0.4.3 lib/decidim/has_feature.rb
decidim-core-0.4.0 lib/decidim/has_feature.rb
decidim-core-0.3.2 lib/decidim/has_feature.rb
decidim-core-0.3.1 lib/decidim/has_feature.rb
decidim-core-0.3.0 lib/decidim/has_feature.rb
decidim-core-0.2.0 lib/decidim/has_feature.rb