Module: Rhosync::Resource::HelperMethods

Defined in:
lib/rhosync/resource.rb

Instance Method Summary collapse

Instance Method Details

#install_callbacksObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rhosync/resource.rb', line 66

def install_callbacks
  if is_datamapper?
    # test for dm-serializer
    if not is_defined?(DataMapper::Serialize)
      raise "Rhosync::Resource requires dm-serializer to work with DataMapper. Install with `gem install dm-serializer` and add to your application."
    end
    after :create, :rhosync_create
    after :destroy, :rhosync_destroy
    after :update, :rhosync_update
  elsif is_activerecord?
    after_create :rhosync_create
    after_destroy :rhosync_destroy
    after_update :rhosync_update
  else
    raise "Rhosync::Resource only supports ActiveRecord or DataMapper at this time."  
  end
end