Sha256: 8899b7b2975bd1fb5e6da1c120f255dd00ba9b743556d5785a6ef5ed57cc2394

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

module Lockdown
  class System
    extend Lockdown::Rules

    def self.configure(&block)
      set_defaults 

      # Defined by the framework
      load_controller_classes

      # Lockdown::Rules defines the methods that are used inside block
      instance_eval(&block)

      # Lockdown::Rules defines process_rules
      process_rules

      Lockdown::Database.sync_with_db unless skip_sync?
    end

    def self.fetch(key)
      (@options||={})[key]
    end

    def self.call(object, system_option)
      method = fetch(system_option)
      if method.is_a?(Symbol) && object.respond_to?(method)
        object.send(method) 
      end
    end

    protected 

    def self.paths_for(str_sym, *methods)
      str_sym = str_sym.to_s if str_sym.is_a?(Symbol)
      if methods.empty?
        klass = fetch_controller_class(str_sym)
        methods = available_actions(klass) 
      end
      path_str = str_sym.gsub("__","\/") 
        
      subdir = Lockdown::System.fetch(:subdirectory)
      path_str = "#{subdir}/#{path_str}" if subdir

      controller_actions = methods.flatten.collect{|m| m.to_s}

      paths = controller_actions.collect{|meth| "#{path_str}/#{meth.to_s}" }

      if controller_actions.include?("index")
        paths += [path_str]
      end

      paths
    end

    def self.fetch_controller_class(str)
      controller_classes[Lockdown.controller_class_name(str)]
    end
  
 end # System class
end # Lockdown

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
blaxter-lockdown-0.9.8.99 lib/lockdown/system.rb
blaxter-lockdown-0.9.9 lib/lockdown/system.rb
lockdown-0.9.0 lib/lockdown/system.rb
lockdown-0.9.3 lib/lockdown/system.rb
lockdown-0.9.1 lib/lockdown/system.rb
lockdown-0.9.2 lib/lockdown/system.rb
lockdown-0.9.7 lib/lockdown/system.rb
lockdown-0.9.5 lib/lockdown/system.rb
lockdown-0.9.8 lib/lockdown/system.rb