class Reativo::JsGenerator

Public Instance Methods

generate_operations() click to toggle source
# File lib/generators/reativo/js_generator.rb, line 31
def generate_operations
  needs_form = false
  actions = options['actions'].empty? ? ['index', 'new', 'show', 'edit'] : options['actions']

  actions.each do |action|
    template "component/#{action.capitalize}.js", component_path(action)
    if needs_form?(action)
      needs_form = true
    end
  end

  if needs_form
    template "component/Form.js", component_path("Form")
  end
end

Private Instance Methods

collection_path() click to toggle source
# File lib/generators/reativo/js_generator.rb, line 58
def collection_path
  class_name.underscore
end
component_path(action) click to toggle source
# File lib/generators/reativo/js_generator.rb, line 54
def component_path(action)
  "app/javascript/components/#{class_name.underscore}/#{action.capitalize}.js"
end
element_path() click to toggle source
# File lib/generators/reativo/js_generator.rb, line 62
def element_path
  class_name.singularize.underscore
end
js_properties() click to toggle source
# File lib/generators/reativo/js_generator.rb, line 74
def js_properties
  options[:properties].join(", ")
end
model_name_plural() click to toggle source
# File lib/generators/reativo/js_generator.rb, line 70
def model_name_plural
  model_name.demodulize.pluralize
end
model_name_singular() click to toggle source
# File lib/generators/reativo/js_generator.rb, line 66
def model_name_singular
  model_name.demodulize.singularize
end
needs_form?(action) click to toggle source
# File lib/generators/reativo/js_generator.rb, line 48
def needs_form?(action)
  return true if action == "new"
  return true if action == "edit"
  false
end