Class: Constantinopolis::Fort
- Inherits:
-
Object
- Object
- Constantinopolis::Fort
- Defined in:
- lib/constantinopolis.rb
Class Method Summary collapse
- .build! ⇒ Object
- .js_code ⇒ Object
- .namespace(namespace = nil) ⇒ Object
- .reload! ⇒ Object
- .yml(path = nil) ⇒ Object
Instance Method Summary collapse
- #build_js! ⇒ Object
-
#build_methods! ⇒ Object
— Instance methods.
- #js_code ⇒ Object
Class Method Details
.build! ⇒ Object
23 24 25 26 |
# File 'lib/constantinopolis.rb', line 23 def build! instance.build_methods! instance.build_js! end |
.js_code ⇒ Object
33 34 35 |
# File 'lib/constantinopolis.rb', line 33 def js_code instance.js_code end |
.namespace(namespace = nil) ⇒ Object
19 20 21 |
# File 'lib/constantinopolis.rb', line 19 def namespace(namespace = nil) @namespace ||= namespace end |
.reload! ⇒ Object
28 29 30 31 |
# File 'lib/constantinopolis.rb', line 28 def reload! @instance = nil build! end |
.yml(path = nil) ⇒ Object
13 14 15 16 17 |
# File 'lib/constantinopolis.rb', line 13 def yml(path = nil) return @yml unless path Constantinopolis::RailsReloader.register(self, path) if defined? Rails @yml = path end |
Instance Method Details
#build_js! ⇒ Object
53 54 55 |
# File 'lib/constantinopolis.rb', line 53 def build_js! @js_code = "#{self.class.name}=#{JSON.generate(@constants)};" end |
#build_methods! ⇒ Object
— Instance methods
47 48 49 50 51 |
# File 'lib/constantinopolis.rb', line 47 def build_methods! @constants.each do |key, value| self.class.define_singleton_method key, ->() { value } end end |
#js_code ⇒ Object
57 58 59 |
# File 'lib/constantinopolis.rb', line 57 def js_code @js_code end |