Class: RjsRails::Runtime::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rjs-rails/runtime/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = nil) ⇒ Config

Returns a new instance of Config.



9
10
11
# File 'lib/rjs-rails/runtime/config.rb', line 9

def initialize(env = nil)
  self.env = env
end

Instance Attribute Details

#build_config=(value) ⇒ Object

Sets the attribute build_config

Parameters:

  • value

    the value to set the attribute build_config to.



7
8
9
# File 'lib/rjs-rails/runtime/config.rb', line 7

def build_config=(value)
  @build_config = value
end

#env=(value) ⇒ Object

Sets the attribute env

Parameters:

  • value

    the value to set the attribute env to.



7
8
9
# File 'lib/rjs-rails/runtime/config.rb', line 7

def env=(value)
  @env = value
end

Instance Method Details

#helperObject



37
38
39
# File 'lib/rjs-rails/runtime/config.rb', line 37

def helper
  ActionController::Base.helpers
end

#module_path(m) ⇒ Object



32
33
34
# File 'lib/rjs-rails/runtime/config.rb', line 32

def module_path(m)
 helper.javascript_path m
end

#module_pathsObject



21
22
23
24
25
# File 'lib/rjs-rails/runtime/config.rb', line 21

def module_paths
  mpaths = {}
  build_config.module_names.map{ |m| mpaths[m] = module_path(m) }
  return mpaths
end

#pathsObject



27
28
29
30
# File 'lib/rjs-rails/runtime/config.rb', line 27

def paths
  paths = build_config.paths
  paths.merge(module_paths)
end

#static_includeObject



13
14
15
# File 'lib/rjs-rails/runtime/config.rb', line 13

def static_include
  @static_include ||= template
end

#templateObject



17
18
19
# File 'lib/rjs-rails/runtime/config.rb', line 17

def template
  "<script>var require = #{JSON.generate(config)}</script>"
end