Sha256: 4f2ab3354427cd293ca9dde000c95dcf0e1ad21d33ea5cb81fc69ae675cb3835

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

class ComponyController < ApplicationController
  # Init
  actions_without_authentication = []

  # Define a controller action for each route
  Components.constants.each do |family_cst|
    Components.const_get(family_cst).constants.each do |comp_cst|
      # Instanciate the component for later information extraction
      comp = Components.const_get(family_cst).const_get(comp_cst).new

      # Standalone configs are already grouped in a hash, one entry per name/path
      comp.standalone_configs.each_value do |standalone_config|
        # Ignore incomplete standalone configs (these come from parent classes )
        next if standalone_config[:path].blank?

        # Define controller action for each standalone config
        define_method(standalone_config.rails_action_name) do
          verb_config = standalone_config.verbs[request.raw_request_method.downcase.to_sym]
          Compony.comp_class_for!(comp_cst, family_cst).new.on_standalone_access(verb_config, self)
        end

        # Disable authentication for marked standalone configs
        actions_without_authentication << standalone_config.rails_action_name.to_sym if standalone_config.skip_authentication
      end
    end
  end

  if Compony.authentication_before_action.present?
    before_action Compony.authentication_before_action, except: actions_without_authentication
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
compony-0.2.0 app/controllers/compony_controller.rb
compony-0.1.1 app/controllers/compony_controller.rb
compony-0.1.0 app/controllers/compony_controller.rb
compony-0.0.9 app/controllers/compony_controller.rb
compony-0.0.8 app/controllers/compony_controller.rb
compony-0.0.7 app/controllers/compony_controller.rb
compony-0.0.6 app/controllers/compony_controller.rb
compony-0.0.5 app/controllers/compony_controller.rb
compony-0.0.4 app/controllers/compony_controller.rb
compony-0.0.3 app/controllers/compony_controller.rb
compony-0.0.2 app/controllers/compony_controller.rb
compony-0.0.1 app/controllers/compony_controller.rb