Sha256: 1fedf2a2bcdbf3d48439a76fb3c9cdcba52bb8bdde312bffe308fdc88211dfc5

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

module Extr
  class Engine < Rails::Engine

    initializer "read_ext_config_from_yaml" do |app|

     yaml_path = Rails.root.join("config", "extdirect.yml")
     if File.exists? yaml_path

      YAML.load_file(yaml_path).each do |klass, options|

       action = options["name"] || klass.gsub("_","")
       Config.controller_path[action]=klass.gsub("_","::").to_s

       keys = ["methods","formHandler"]

       (options.keys & keys).each do |key|
        unless options[key].nil?
         options[key].stringify_keys!.each do |mtd, mcfg|
          method_hash = mcfg.is_a?(Hash) ? {'name' => mtd}.merge!(mcfg) : {'name' => mtd, 'len' => mcfg || 1}
          method_hash[key]= true if key == "formHandler"
          Config.controller_config[action] << method_hash
         end
        end

       #END KEY LOOP
       end

      #END YAML_LOAD_FILE
      end

     end

    end

   end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
extr-1.0.0 lib/extr/engine.rb