Class: ActiveRecord::Generators::PaypalPermissionsGenerator

Inherits:
Base
  • Object
show all
Includes:
PaypalPermissions::Generators::OrmHelpers
Defined in:
lib/generators/active_record/paypal_permissions_generator.rb

Instance Method Summary collapse

Methods included from PaypalPermissions::Generators::OrmHelpers

#migration_exists?, #migration_path, #model_contents, #model_exists?, #model_path

Instance Method Details

#copy_paypal_permissions_migrationObject



12
13
14
15
16
17
18
# File 'lib/generators/active_record/paypal_permissions_generator.rb', line 12

def copy_paypal_permissions_migration
  if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
    migration_template "migration_existing.rb", "db/migrate/add_paypal_permissions_to_#{table_name}"
  else
    migration_template "migration.rb", "db/migrate/paypal_permissions_create_#{table_name}"
  end
end

#generate_paypal_permissions_modelObject



20
21
22
# File 'lib/generators/active_record/paypal_permissions_generator.rb', line 20

def generate_paypal_permissions_model
  invoke "active_record:model", [ name ], :migration => false unless model_exists? && behavior == :invoke
end

#indexesObject



38
39
40
41
# File 'lib/generators/active_record/paypal_permissions_generator.rb', line 38

def indexes
<<INDEXES
INDEXES
end

#inject_paypal_permissions_contentObject



24
25
26
27
28
# File 'lib/generators/active_record/paypal_permissions_generator.rb', line 24

def inject_paypal_permissions_content
  inject_into_class(model_path, class_name, model_contents + <<ACCESSIBLE_FIELDS) if model_exists?
  attr_accessible :ppp_access_token, :ppp_access_token_verifier
ACCESSIBLE_FIELDS
end

#migration_dataObject



30
31
32
33
34
35
36
# File 'lib/generators/active_record/paypal_permissions_generator.rb', line 30

def migration_data
<<MIGRATION_FIELDS
# GetAccessToken response fields
t.string :ppp_access_token
t.string :ppp_access_token_verifier
MIGRATION_FIELDS
end