Class: Pigeon::NuntiumChannel
- Inherits:
-
Channel
- Object
- Channel
- Pigeon::NuntiumChannel
show all
- Defined in:
- app/models/pigeon/nuntium_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!, schemas, #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
17
18
19
20
21
|
# File 'app/models/pigeon/nuntium_channel.rb', line 17
def list
nuntium.channels.map do |data|
data['name']
end
end
|
.nuntium ⇒ Object
23
24
25
|
# File 'app/models/pigeon/nuntium_channel.rb', line 23
def nuntium
@nuntium ||= ::Pigeon::Nuntium.from_config
end
|
.type ⇒ Object
5
|
# File 'app/models/pigeon/nuntium_channel.rb', line 5
def type() :nuntium end
|
Instance Method Details
#destroy ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'app/models/pigeon/nuntium_channel.rb', line 79
def destroy
if !destroyed?
begin
if persisted?
self.class.nuntium.delete_channel(name)
end
@destroyed = true
rescue Pigeon::NuntiumException => e
Rails.logger.warn "error deleting Nuntium channel: #{e.message}"
end
end
end
|
#save ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/models/pigeon/nuntium_channel.rb', line 53
def save
return false unless valid?
begin
if !persisted?
self.class.nuntium.create_channel attributes
@persisted = true
else
self.class.nuntium.update_channel attributes
end
true
rescue Pigeon::NuntiumException => e
Rails.logger.warn "error saving Nuntium channel: #{e.message}"
e.properties.each do |name, message|
if attributes.include? name
errors.add name, message
elsif configuration.include? name
errors.add "configuration[#{name}]", message
else
errors.add :base, "#{name} #{message}"
end
end
false
end
end
|
#schemas ⇒ Object
8
9
10
|
# File 'app/models/pigeon/nuntium_channel.rb', line 8
def schemas
load_schemas
end
|