Sha256: 047683f8b15fe959e93884a63f7133e1aa0c622a6630b6b73fb1029e29565fea

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require "decidim/settings_manifest"

module Decidim
  # This class handles all the logic associated to configuring a participatory
  # space, the highest level object of Decidim.
  #
  # It's normally not used directly but through the API exposed through
  # `Decidim.register_participatory_space`.
  class ParticipatorySpaceManifest
    include ActiveModel::Model
    include Virtus.model

    attribute :admin_engine, Rails::Engine
    attribute :engine, Rails::Engine

    attribute :name, Symbol

    # The ActiveRecord class name of the model we're exposing
    attribute :model_class_name, String

    # The name of the named Rails route to create the url to the resource.
    # When not explicitly set, it will use the model name.
    attribute :route_name, String

    # A String with the feature's icon. The icon must be stored in the
    # engine's assets path.
    attribute :icon, String

    validates :name, presence: true

    # Public: A block that gets called when seeding for this feature takes place.
    #
    # Returns nothing.
    def seeds(&block)
      @seeds = block
    end

    # Public: Creates the seeds for this features in order to populate the database.
    #
    # Returns nothing.
    def seed!
      @seeds&.call
    end

    # The name of the named Rails route to create the url to the resource.
    #
    # Returns a String.
    def route_name
      super || model_class_name.demodulize.underscore
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

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