Class: Resty::Generators::ModelGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/resty/model/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#actionsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/generators/resty/model/model_generator.rb', line 40

def actions
  @actions ||= 
    begin
      keys = action_map.keys
      if options[:singleton]
        keys.delete('index')
        keys.delete('create')
        keys.delete('destroy')
      end
      if options[:read_only]
        keys.delete('update')
        keys.delete('create')
        keys.delete('destroy')
      end
      keys
    end
end

#controller_class_nameObject



36
37
38
# File 'lib/generators/resty/model/model_generator.rb', line 36

def controller_class_name
  @controller_class_name ||= class_name.pluralize
end

#create_cache_fileObject



21
22
23
24
25
# File 'lib/generators/resty/model/model_generator.rb', line 21

def create_cache_file
  if !options[:singleton] && !options[:read_only]
    template 'Cache.java', File.join(java_root, caches_package.gsub(/\./, "/"), class_path, "#{class_name.pluralize}Cache.java")
  end
end

#create_event_filesObject



27
28
29
30
# File 'lib/generators/resty/model/model_generator.rb', line 27

def create_event_files
  template 'Event.java', File.join(java_root, events_package.gsub(/\./, "/"), class_path, "#{class_name}Event.java")
  template 'EventHandler.java', File.join(java_root, events_package.gsub(/\./, "/"), class_path, "#{class_name}EventHandler.java")
end

#create_model_fileObject



17
18
19
# File 'lib/generators/resty/model/model_generator.rb', line 17

def create_model_file
  template 'Model.java', File.join(java_root, models_package.gsub(/\./, "/"), class_path, "#{class_name}.java")
end

#create_rest_service_fileObject



32
33
34
# File 'lib/generators/resty/model/model_generator.rb', line 32

def create_rest_service_file
  template 'RestService.java', File.join(java_root, restservices_package.gsub(/\./, "/"), class_path, "#{controller_class_name}RestService.java")
end