Module: Cloudfuji::Models::ClassMethods

Defined in:
lib/cloudfuji/models.rb

Instance Method Summary collapse

Instance Method Details

#cloudfuji(model) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cloudfuji/models.rb', line 43

def cloudfuji model
  self.class_variable_set("@@ido_model", model)

  [:create, :update, :destroy].each do |event|
    puts "Hooking into #{model}.#{event}..."

    Cloudfuji::Data.listen("#{model}.#{event}") do |data, hook|
      puts "#{hook}.) Firing off #{model}.#{event} now with data: #{data}"
      self.send("on_cloudfuji_#{event}".to_sym, self.from_cloudfuji(data))
    end
  end
  
  before_save :cloudfuji_save
end