Class: Atrium::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/atrium/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_controllersObject



57
58
59
# File 'lib/generators/atrium/install/install_generator.rb', line 57

def create_controllers
  raw_install('controllers')
end

#create_helpersObject



65
66
67
# File 'lib/generators/atrium/install/install_generator.rb', line 65

def create_helpers
  raw_install('helpers')
end

#create_initializerObject



4
5
6
7
8
9
# File 'lib/generators/atrium/install/install_generator.rb', line 4

def create_initializer
  template(
    'atrium_initializer.rb',
    'config/initializers/atrium.rb'
  )
end

#create_modelsObject



61
62
63
# File 'lib/generators/atrium/install/install_generator.rb', line 61

def create_models
  raw_install('models')
end

#create_viewsObject



69
70
71
# File 'lib/generators/atrium/install/install_generator.rb', line 69

def create_views
  raw_install('views')
end

#update_controllersObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/atrium/install/install_generator.rb', line 24

def update_controllers
  inject_into_class(
    'app/controllers/application_controller.rb',
    'ApplicationController'
  ) do
    [
      "",
      "  def blacklight_config",
      "    CatalogController.blacklight_config",
      "  end",
      "  helper_method :blacklight_config",
      "  protected :blacklight_config",
      ""
    ].join("\n")
  end
end

#update_routesObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/atrium/install/install_generator.rb', line 11

def update_routes
  route(%q{mount Atrium::Engine => '/atrium', as: 'atrium'})
  route(%q{resources :collections, only: [:show] do
    get 'browse', on: :member
  end})
  route(%q{resources :exhibits, only: [:show]})
  route(%q{resources :descriptions})
  route(%q{match 'selected_items/save',
    to: 'selected_items#save',
    as: 'save_selected_items',
    via: :post})
end

#update_user_modelObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/generators/atrium/install/install_generator.rb', line 41

def update_user_model
  inject_into_file 'app/models/user.rb',
    :before => "def to_s" do
    [
        "",
        " has_many     :selected_items, :class_name => 'SelectedItem',   :dependent => :destroy",
        "",
        " def selected_document_ids",
        "   self.selected_items.map{|item|item.document_id}",
        " end",
        "",
        ""
    ].join("\n")
  end
end