Sha256: 2604df8e96eb17a954c80f7a8b2f608894986fe436e3f73bc7d065edc76aab26

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/attribute_accessors'

module Cmor
  module Core
    module Backend
      module Configuration
        extend self

        def configure
          yield self
        end

        mattr_accessor(:image_variant_options) {
          {
            gallery: { resize: "640x480" },
            table:   { resize: "160x120" }
          }
        }

        mattr_accessor(:resources_routes) { {} }

        def image_variant_options_for(identifier)
          image_variant_options[identifier]
        end

        # You can add routes to resources based an any condition that can based
        # on the controller or resource class that a route is used for.
        #
        # This is useful when writing modules that conditionally add actions to
        # resources based on the capabilities of the controller or resource class.
        #
        # Example:
        #
        #     config.add_resources_routes(
        #       :cmor_audits,
        #       condition: ->{ resource_class.ancestors.map(&:to_s).include?("PaperTrail::Model::InstanceMethods") },
        #       routes:    ->{ paper_trail_resources }
        #     )
        #
        # Example:
        #
        #     config.add_resources_routes(
        #       :acts_as_list,
        #       condition: ->{ resource_class.respond_to?(:position) },
        #       routes:    ->{ get :toggle_position, on: :member }
        #     )
        #
        def add_resources_routes(name, options)
          resources_routes[name] = options
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cmor_core_backend-0.0.60.pre lib/cmor/core/backend/configuration.rb
cmor_core_backend-0.0.59.pre lib/cmor/core/backend/configuration.rb
cmor_core_backend-0.0.58.pre lib/cmor/core/backend/configuration.rb
cmor_core_backend-0.0.57.pre lib/cmor/core/backend/configuration.rb
cmor_core_backend-0.0.56.pre lib/cmor/core/backend/configuration.rb