Sha256: 7859121bbd021043adae328f22b80e121f9ef2c60730ff29a60026e58e2ab328
Contents?: true
Size: 1.97 KB
Versions: 4
Compression:
Stored size: 1.97 KB
Contents
require File.join(File.dirname(__FILE__), "merb", "controller") require File.join(File.dirname(__FILE__), "merb", "view") module Lockdown module Frameworks module Merb class << self def use_me? Object.const_defined?("Merb") && ::Merb.const_defined?("AbstractController") end def included(mod) mod.extend Lockdown::Frameworks::Merb::Environment mixin end def mixin Lockdown.controller_parent.send :include, Lockdown::Frameworks::Merb::Controller::Lock Lockdown.view_helper.send :include, Lockdown::Frameworks::Merb::View Lockdown::System.send :extend, Lockdown::Frameworks::Merb::System end end # class block module Environment def project_root ::Merb.root end def controller_parent ::Merb::Controller end def view_helper ::Merb::AssetsMixin end def controller_class_name(str) if str.include?("__") str.split("__").collect{|p| Lockdown.camelize(p)}.join("::") else Lockdown.camelize(str) end end end module System include Lockdown::Frameworks::Merb::Controller def load_controller_classes @controller_classes = {} maybe_load_framework_controller_parent Dir.chdir("#{Lockdown.project_root}/app/controllers") do Dir["**/*.rb"].sort.each do |c| next if c == "application.rb" lockdown_load(c) end end end def maybe_load_framework_controller_parent load("application.rb") unless const_defined?("Application") end def lockdown_load(file) klass = Lockdown.class_name_from_file(file) @controller_classes[klass] = Lockdown.qualified_const_get(klass) end end # System end # Merb end # Frameworks end # Lockdown
Version data entries
4 entries across 4 versions & 1 rubygems