Class: Oauned::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Oauned::Generators::InstallGenerator
show all
- Includes:
- Helpers
- Defined in:
- lib/generators/oauned/install_generator.rb
Instance Method Summary
collapse
Methods included from Helpers
#model_exists?, #model_path
Instance Method Details
#add_oauned_routes ⇒ Object
11
12
13
|
# File 'lib/generators/oauned/install_generator.rb', line 11
def add_oauned_routes
route "scope '/scoped' { oauned_routing }"
end
|
#create_models ⇒ Object
15
16
17
18
19
|
# File 'lib/generators/oauned/install_generator.rb', line 15
def create_models
[:application, :authorization, :connection].each do |model|
invoke "active_record:model", [model], :migration => false unless model_exists?(model) && behavior == :invoke
end
end
|
#inject_application_content ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/generators/oauned/install_generator.rb', line 21
def inject_application_content
inject_into_class model_path(:application), Application, <<EOS if model_exists?(:authorization)
include Oauned::Models::Application
has_many :authorizations
has_many :connections
EOS
end
|
#inject_authorization_content ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/generators/oauned/install_generator.rb', line 30
def inject_authorization_content
inject_into_class model_path(:authorization), Application, <<EOS if model_exists?(:authorization)
include Oauned::Models::Authorization
belongs_to :user
belongs_to :application
EOS
end
|
#inject_connection_content ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/generators/oauned/install_generator.rb', line 39
def inject_connection_content
inject_into_class model_path(:connection), Application, <<EOS if model_exists?(:authorization)
include Oauned::Models::Connection
belongs_to :user
belongs_to :application
EOS
end
|