Sha256: c38cf13b1d7e07573a90b1954a8497a0362365be4697f0871cd09a28b5f2be24
Contents?: true
Size: 1.87 KB
Versions: 24
Compression:
Stored size: 1.87 KB
Contents
module ActiveScaffold module Bridges ActiveScaffold.autoload_subdir('bridges', self) module Shared autoload :DateBridge, 'active_scaffold/bridges/shared/date_bridge' end 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
24 entries across 24 versions & 1 rubygems