Module: Lanes::Extensions
- Defined in:
- lib/lanes/extension.rb
Defined Under Namespace
Classes: Definition
Class Method Summary collapse
- .all ⇒ Object
- .client_bootstrap_data(view) ⇒ Object
- .each ⇒ Object
- .early_loaded ⇒ Object
- .late_loaded ⇒ Object
- .load_after(extension) ⇒ Object
- .load_before(extension) ⇒ Object
- .load_current_config ⇒ Object
- .sorted ⇒ Object
Class Method Details
.all ⇒ Object
59 60 61 |
# File 'lib/lanes/extension.rb', line 59 def all Definition.descendants end |
.client_bootstrap_data(view) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/lanes/extension.rb', line 99 def client_bootstrap_data(view) data = {} each do | ext | data[ext.identifier] = ext.client_bootstrap_data(view) end return data end |
.each ⇒ Object
87 88 89 |
# File 'lib/lanes/extension.rb', line 87 def each sorted.map{ |klass| yield klass.new } end |
.early_loaded ⇒ Object
91 92 93 |
# File 'lib/lanes/extension.rb', line 91 def early_loaded each{ |ext| yield ext if ext.load_phase == :early } end |
.late_loaded ⇒ Object
95 96 97 |
# File 'lib/lanes/extension.rb', line 95 def late_loaded each{ |ext| yield ext if ext.load_phase == :late } end |
.load_after(extension) ⇒ Object
51 52 53 |
# File 'lib/lanes/extension.rb', line 51 def load_after(extension) self.after = extension end |
.load_before(extension) ⇒ Object
55 56 57 |
# File 'lib/lanes/extension.rb', line 55 def load_before(extension) self.before = extension end |
.load_current_config ⇒ Object
107 108 109 110 111 112 |
# File 'lib/lanes/extension.rb', line 107 def load_current_config config_file = Pathname.getwd.join('config','lanes.rb') if config_file.exist? require config_file end end |
.sorted ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/lanes/extension.rb', line 63 def sorted unmapped = all mapped = [] while unmapped.any? mapped_count = mapped.length unmapped.each do | ext | if !ext.before && !ext.after mapped.push(ext) end if ext.before && (position = mapped.find_index(ext.before)) mapped.insert(position, ext) end if ext.after && (position = mapped.find_index(ext.after)) mapped.insert(position+1, ext) end end if mapped_count == mapped.length # we failed to add any extensions Lanes.logger.info "Conflicting load directives. Some extensions will not be available" end unmapped -= mapped end mapped end |