Sha256: 9f13c3b7d9da788658bb2fcd2b9712d1b2f69dc2e1c006a6b0a141b715394a05
Contents?: true
Size: 1.77 KB
Versions: 8
Compression:
Stored size: 1.77 KB
Contents
module ActiveScaffold module Bridges ActiveScaffold.autoload_subdir('bridges', self) mattr_accessor :bridges mattr_accessor :bridges_run mattr_accessor :bridges_prepared self.bridges = {} def self.register(file) match = file.match(%r{(active_scaffold/bridges/(.*))\.rb\Z}) bridges[match[2].to_sym] = match[1] if match end def self.load(bridge_name) bridge = bridges[bridge_name.to_sym] if bridge.is_a? String if ActiveScaffold.exclude_bridges.exclude? bridge_name.to_sym bridge = bridge.camelize.constantize bridges[bridge_name.to_sym] = bridge else bridges.delete bridge_name bridge = nil end end bridge end class << self alias [] load end def self.run_all return false if bridges_run bridges.each_key do |bridge_name| self[bridge_name]&.run end ActiveScaffold::Config::Core.freeze if ActiveScaffold.threadsafe self.bridges_run = true end def self.prepare_all return false if bridges_prepared bridges.each_key do |bridge_name| bridge = self[bridge_name] bridge.prepare if bridge&.install? end self.bridges_prepared = true end def self.all_stylesheets bridges.keys.collect do |bridge_name| bridge = self[bridge_name] bridge.stylesheets if bridge&.install? end.compact.flatten end def self.all_javascripts bridges.keys.collect do |bridge_name| bridge = self[bridge_name] bridge.javascripts if bridge&.install? end.compact.flatten end end end Dir[File.join(File.dirname(__FILE__), 'bridges/*.rb')].each do |bridge| ActiveScaffold::Bridges.register bridge unless bridge == __FILE__ end
Version data entries
8 entries across 8 versions & 1 rubygems