Sha256: d1e417687cbb837a3076d0d4f7843a8e7868e82fb6b9b8cb6c8ebbff0105165a

Contents?: true

Size: 628 Bytes

Versions: 28

Compression:

Stored size: 628 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"
      delegate :organization, to: :feature, allow_nil: true
    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

28 entries across 28 versions & 2 rubygems

Version Path
decidim-core-0.8.4 lib/decidim/has_feature.rb
decidim-core-0.8.3 lib/decidim/has_feature.rb
decidim-core-0.8.2 lib/decidim/has_feature.rb
decidim-core-0.8.1 lib/decidim/has_feature.rb
decidim-core-0.8.0 lib/decidim/has_feature.rb
decidim-core-0.7.4 lib/decidim/has_feature.rb
decidim-core-0.7.3 lib/decidim/has_feature.rb
decidim-core-0.7.2 lib/decidim/has_feature.rb
decidim-core-0.7.1 lib/decidim/has_feature.rb
decidim-core-0.7.0 lib/decidim/has_feature.rb
decidim-core-0.6.8 lib/decidim/has_feature.rb
decidim-0.6.8 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.7 lib/decidim/has_feature.rb
decidim-0.6.7 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.6 lib/decidim/has_feature.rb
decidim-0.6.6 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.5 lib/decidim/has_feature.rb
decidim-0.6.5 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.4 lib/decidim/has_feature.rb
decidim-0.6.4 decidim-core/lib/decidim/has_feature.rb