Class: Kaui::AccountEmail
Instance Attribute Summary
Attributes inherited from Base
#errors
Class Method Summary
collapse
Instance Method Summary
collapse
#as_string
Methods inherited from Base
#==, all, #attributes=, camelize, convert_hash_keys, count, define_attr, find, from_json, has_many, has_one, human_attribute_name, lookup_ancestors, #new_record?, #persisted?, #read_attribute_for_validation, #to_hash, to_money, #update_attributes
Constructor Details
#initialize(attributes = {}) ⇒ AccountEmail
Returns a new instance of AccountEmail.
9
10
11
12
13
14
15
16
|
# File 'app/models/kaui/account_email.rb', line 9
def initialize(attributes = {})
super(attributes)
@persisted = false
end
|
Class Method Details
.where(conditions) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/models/kaui/account_email.rb', line 18
def self.where(conditions)
begin
account_emails = Kaui::KillbillHelper.get_account_emails(conditions[:account_id]) || []
return account_emails.sort unless conditions[:email].present?
account_emails.each do |account_email|
return account_email if account_email.email == conditions[:email]
end
rescue => e
@errors.add(:where, "Error while getting account emails: #{as_string(e)}")
end
[]
end
|
Instance Method Details
#<=>(account_email) ⇒ Object
59
60
61
|
# File 'app/models/kaui/account_email.rb', line 59
def <=>(account_email)
@email <=> account_email.email
end
|
#destroy ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'app/models/kaui/account_email.rb', line 42
def destroy
begin
Kaui::KillbillHelper.remove_account_email(self)
true
rescue => e
@errors.add(:destroy, "Error while trying to delete an account email: #{as_string(e)}")
end
end
|
#id ⇒ Object
51
52
53
|
# File 'app/models/kaui/account_email.rb', line 51
def id
to_param
end
|
#save ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'app/models/kaui/account_email.rb', line 32
def save
begin
Kaui::KillbillHelper.add_account_email(self)
true
rescue => e
@errors.add(:save, "Error while trying to add an account email: #{as_string(e)}")
false
end
end
|
#to_param ⇒ Object
55
56
57
|
# File 'app/models/kaui/account_email.rb', line 55
def to_param
@account_id
end
|