Class: Volt::ComponentCode
- Defined in:
- lib/volt/server/rack/component_code.rb
Instance Method Summary collapse
-
#code ⇒ Object
The client argument is for if this code is being generated for the client.
- #generate_config_code ⇒ Object
-
#initialize(component_name, component_paths, client = true) ⇒ ComponentCode
constructor
A new instance of ComponentCode.
Constructor Details
#initialize(component_name, component_paths, client = true) ⇒ ComponentCode
Returns a new instance of ComponentCode.
9 10 11 12 13 |
# File 'lib/volt/server/rack/component_code.rb', line 9 def initialize(component_name, component_paths, client = true) @component_name = component_name @component_paths = component_paths @client = client end |
Instance Method Details
#code ⇒ Object
The client argument is for if this code is being generated for the client
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/volt/server/rack/component_code.rb', line 16 def code # Start with config code code = @client ? generate_config_code : '' asset_files = AssetFiles.new(@component_name, @component_paths) asset_files.component_paths.each do |component_path, component_name| code << ComponentTemplates.new(component_path, component_name, @client).code code << "\n\n" end code end |
#generate_config_code ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/volt/server/rack/component_code.rb', line 29 def generate_config_code # Setup Volt.config on the client code = "\nVolt.setup_client_config(#{Volt.config.public.to_h.inspect})\n" # Include the root initializers code << "require_tree '#{Volt.root}/config/initializers'\n" code << "require_tree '#{Volt.root}/config/initializers/client'\n" code end |