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.6.3 lib/decidim/has_feature.rb
decidim-0.6.3 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.2 lib/decidim/has_feature.rb
decidim-0.6.2 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.1 lib/decidim/has_feature.rb
decidim-0.6.1 decidim-core/lib/decidim/has_feature.rb
decidim-core-0.6.0 lib/decidim/has_feature.rb
decidim-0.6.0 decidim-core/lib/decidim/has_feature.rb