Class: Cloudfuji::Generators::HooksGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/cloudfuji/hooks_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_hooks_fileObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/cloudfuji/hooks_generator.rb', line 5

def create_hooks_file

  lib("cloudfuji/hooks/user_hooks.rb") do
"class CloudfujiUserHooks < Cloudfuji::EventObserver\n  def user_added\n    user.create(:email  => params['data']['email'],\n:ido_id => params['data']['ido_id'],\n:active => true)\n  end\n\n  def user_removed\n    User.find_by_ido_id(params['data']['ido_id']).try(:disable!)\n  end\nend\n"
  end
  
  lib('cloudfuji/hooks/app_hooks.rb') do
"class CloudfujiAppHooks < Cloudfuji::EventObserver\n  def app_claimed\n    User.find(1).update_attributes(:email  => params['data']['email'],\n:ido_id => params['data']['ido_id'])\n  end\nend\n"
  end
  
  initializer "cloudfuji_hooks.rb" do
"Dir[\"\\\#{Dir.pwd}/lib/cloudfuji/**/*.rb\"].each { |file| require file }\n"
  end
end