class Resourceable::Generators::ResourceGenerator

Public Instance Methods

controller() click to toggle source
# File lib/generators/resourceable/resource_generator.rb, line 12
def controller 
  generate 'controller', name.titleize.pluralize
  
  puts "app/controllers/#{name.downcase.pluralize}_coontroller.rb"
  puts "#{name.titleize.pluralize}Controller"

  inject_into_class controller_path, controller_name, 
    "\tcrud permitted: #{attribute_keys}\n"    
end
model() click to toggle source
# File lib/generators/resourceable/resource_generator.rb, line 8
def model
  generate 'model', "#{name} #{attributes_cli_options}"
end

Private Instance Methods

attribute_keys() click to toggle source
# File lib/generators/resourceable/resource_generator.rb, line 28
def attribute_keys
  options[:attributes].symbolize_keys.keys
end
attributes_cli_options() click to toggle source
# File lib/generators/resourceable/resource_generator.rb, line 24
def attributes_cli_options
  options[:attributes].map{ |k,v| "#{k}:#{v}" }.join(' ')
end
controller_name() click to toggle source
# File lib/generators/resourceable/resource_generator.rb, line 32
def controller_name 
  "#{name.titleize.pluralize}Controller" 
end
controller_path() click to toggle source
# File lib/generators/resourceable/resource_generator.rb, line 36
def controller_path
  "app/controllers/#{name.downcase.pluralize}_controller.rb"
end