Sha256: 25451e69542db854ccd73e7f691f2e2490f965b0d4ef56e71722cd95c457ca62

Contents?: true

Size: 695 Bytes

Versions: 6

Compression:

Stored size: 695 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
      delegate :participatory_space, 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

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.10.1 lib/decidim/has_feature.rb
decidim-core-0.10.0 lib/decidim/has_feature.rb
decidim-core-0.9.3 lib/decidim/has_feature.rb
decidim-core-0.9.2 lib/decidim/has_feature.rb
decidim-core-0.9.1 lib/decidim/has_feature.rb
decidim-core-0.9.0 lib/decidim/has_feature.rb