lib/errbit/cloudfuji.rb in errbit_cloudfuji-0.1.0 vs lib/errbit/cloudfuji.rb in errbit_cloudfuji-0.1.1
- old
+ new
@@ -2,43 +2,35 @@
module Cloudfuji
class << self
def enable_cloudfuji!
load_hooks!
extend_user!
- extend_notice!
+ extend_err!
disable_devise_for_cloudfuji_controllers!
end
def extend_user!
puts "Extending the user model"
- User.instance_eval do
+ User.class_eval do
+ field :ido_id
validates_presence_of :ido_id
validates_uniqueness_of :ido_id
- end
- User.class_eval do
def cloudfuji_extra_attributes(extra_attributes)
self.name = "#{extra_attributes['first_name'].to_s} #{extra_attributes['last_name'].to_s}"
self.email = extra_attributes["email"]
self.admin = true
end
end
end
- def extend_notice!
- Notice.class_eval do
- def publish_cloudfuji_event
- human_message = "App at #{server_environment['hostname']} error"
- ::Cloudfuji::Event.publish({
- :category => :app,
- :name => :error,
- :data => {
- :human => human_message,
- :source => "Errbit",
- :url => "#{ENV['PUBLIC_URL']}/#tickets/#{self.to_param}"
- }
- })
- end
+ def extend_err!
+ Err.class_eval do
+ field :ido_id
+ validates_presence_of :ido_id
+ validates_uniqueness_of :ido_id
+
+ before_validation Proc.new { |e| e.ido_id ||= UUID.new.generate }
end
end
def load_hooks!
Dir["#{Dir.pwd}/lib/cloudfuji/**/*.rb"].each { |file| require file }