Class: Pigeon::VerboiceChannel
- Inherits:
-
Channel
- Object
- Channel
- Pigeon::VerboiceChannel
show all
- Defined in:
- app/models/pigeon/verboice_channel.rb
Instance Attribute Summary
Attributes inherited from Channel
#attributes, #schema
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Channel
#[], #[]=, all, #assign_attributes, channel_accessor, #destroyed?, find, find_schema, find_type, first, #generate_name, #generate_name!, #human_attribute_name, i18n_scope, #initialize, #known_attributes, last, #method_missing, #new_record?, #persisted?, #read_attribute, #read_attribute_for_validation, #save!, #type, #write_attribute
#find_attr_recursive, #find_attr_ref_recursive, #fold_scoped_name
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Pigeon::Channel
Class Method Details
.list ⇒ Object
11
12
13
|
# File 'app/models/pigeon/verboice_channel.rb', line 11
def list
verboice.list_channels
end
|
.schemas ⇒ Object
7
8
9
|
# File 'app/models/pigeon/verboice_channel.rb', line 7
def schemas
@schemas ||= load_schemas
end
|
.type ⇒ Object
5
|
# File 'app/models/pigeon/verboice_channel.rb', line 5
def type() :verboice end
|
.verboice ⇒ Object
15
16
17
|
# File 'app/models/pigeon/verboice_channel.rb', line 15
def verboice
@verboice ||= ::Pigeon::Verboice.from_config
end
|
Instance Method Details
#destroy ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/models/pigeon/verboice_channel.rb', line 68
def destroy
if !destroyed?
begin
if persisted?
self.class.verboice.delete_channel(name)
end
@destroyed = true
rescue Pigeon::VerboiceException => e
Rails.logger.warn "error deleting Verboice channel: #{e.message}"
end
end
end
|
#limit ⇒ Object
38
39
40
|
# File 'app/models/pigeon/verboice_channel.rb', line 38
def limit
config[:limit].to_i || 1
end
|
#save ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/models/pigeon/verboice_channel.rb', line 42
def save
return false unless valid?
begin
if !persisted?
self.class.verboice.create_channel attributes
@persisted = true
else
self.class.verboice.update_channel attributes
end
true
rescue Pigeon::VerboiceException => e
Rails.logger.warn "error saving Verboice channel: #{e.message}"
e.properties.each do |name, message|
if attributes.include? name
errors.add name, message
elsif config.include? name
errors.add "config[#{name}]", message
else
errors.add :base, "#{name} #{message}"
end
end
false
end
end
|