Sha256: 45361079b36e953118e489e932435a2c5344eab64a62ecfb6d71ac81e0a7710f

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

module Lockdown
  class System
    extend Lockdown::Rules

    def self.configure(&block)
      set_defaults 

      # 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?

      @initialized = true if Lockdown.caching?
    end

    def self.initialized?
      @initialized
    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 = Lockdown.fetch_controller_class(str_sym)
        methods = available_actions(klass) 
      end
      path_str = str_sym.gsub("__","\/") 

      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
 end # System class
end # Lockdown

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
revo-lockdown-1.6.2.2 lib/lockdown/system.rb
revo-lockdown-1.6.2.1 lib/lockdown/system.rb
revo-lockdown-1.6.2 lib/lockdown/system.rb