Class: JsGenerator::AppJs

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setup_js) ⇒ AppJs

Returns a new instance of AppJs.



10
11
12
13
14
15
# File 'lib/js_generator/app_js.rb', line 10

def initialize(setup_js)
  @namespace = setup_js.namespace
  @model_name = setup_js.model_name
  @action_name = setup_js.action_name
  @top_level_js_namespace = setup_js.top_level_js_namespace
end

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



8
9
10
# File 'lib/js_generator/app_js.rb', line 8

def action_name
  @action_name
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



8
9
10
# File 'lib/js_generator/app_js.rb', line 8

def model_name
  @model_name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



8
9
10
# File 'lib/js_generator/app_js.rb', line 8

def namespace
  @namespace
end

#top_level_js_namespaceObject (readonly)

Returns the value of attribute top_level_js_namespace.



8
9
10
# File 'lib/js_generator/app_js.rb', line 8

def top_level_js_namespace
  @top_level_js_namespace
end

Instance Method Details

#action_namespaceObject



23
24
25
# File 'lib/js_generator/app_js.rb', line 23

def action_namespace
  syntax_builder.action_namespace
end

#append_scriptObject



17
18
19
20
21
# File 'lib/js_generator/app_js.rb', line 17

def append_script
  File.open("app/javascript/packs/application.js", 'a') do |f|
    f << syntax_builder.script_for_append
  end
end