Class: PandaPal::Organization
Class Method Summary
collapse
Instance Method Summary
collapse
build_settings_entry, #generate_schedule, #sync_schedule
#settings_structure, #validate_settings
Class Method Details
.current ⇒ Object
71
72
73
|
# File 'app/models/panda_pal/organization.rb', line 71
def self.current
find_by_name(Apartment::Tenant.current)
end
|
91
92
93
|
# File 'app/models/panda_pal/organization.rb', line 91
def self.resolve_platform(hint)
iss = hint["iss"]
end
|
Instance Method Details
#create_api(logic, expiration: nil, uses: nil, host: nil) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/models/panda_pal/organization.rb', line 79
def create_api(logic, expiration: nil, uses: nil, host: nil)
switch_tenant do
logic = "current_organization.#{logic}" if logic.is_a?(Symbol)
ac = ApiCall.create!(
logic: logic,
expiration: expiration,
uses_remaining: uses,
)
ac.call_url(host: host)
end
end
|
#encryption_key ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'app/models/panda_pal/organization.rb', line 53
def encryption_key
if (Rails.application.secrets.secret_key_base)
Rails.application.secrets.secret_key_base[0,32]
else
ENV["SECRET_KEY_BASE"][0,32]
end
end
|
#rename!(new_name) ⇒ Object
95
96
97
98
99
100
101
102
103
|
# File 'app/models/panda_pal/organization.rb', line 95
def rename!(new_name)
do_switch = Apartment::Tenant.current == name
ActiveRecord::Base.connection.execute(
"ALTER SCHEMA \"#{name}\" RENAME TO \"#{new_name}\";"
)
self.class.where(id: id).update_all(name: new_name)
reload
switch_tenant if do_switch
end
|
#switch_tenant(&block) ⇒ Object
63
64
65
66
67
68
69
|
# File 'app/models/panda_pal/organization.rb', line 63
def switch_tenant(&block)
if block_given?
Apartment::Tenant.switch(name, &block)
else
Apartment::Tenant.switch!(name)
end
end
|