Class: Constantinopolis::Fort

Inherits:
Object
  • Object
show all
Defined in:
lib/constantinopolis.rb

Class Method Summary collapse

Instance Method Summary collapse

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_codeObject



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_codeObject



57
58
59
# File 'lib/constantinopolis.rb', line 57

def js_code
  @js_code
end