Skip to content

Add the possibility to rate any DataMapper::Resource by remixing a Rating module

License

Notifications You must be signed in to change notification settings

snusnu/dm-is-rateable

Repository files navigation

dm-is-rateable

A DataMapper plugin that adds the ability to rate any model (the 5 clickable stars I see everywhere).


# GEM_DEPENDENCIES = [
#  ["dm-core",         ">=0.9.4"], 
#  ["dm-is-remixable", ">=0.9.4"], 
#  ["dm-validations",  ">=0.9.4"],
#  ["dm-aggregates",   ">=0.9.4"],
#  ["dm-timestamps",   ">=0.9.4"],
#  ["dm-types",        ">=0.9.4"],
# ]
  
class User
  include DataMapper::Resource
  property :id, Serial
end

class Trip

  include DataMapper::Resource
  property :id, Serial

  # will define and thus auto_migrate! by using dm-is-remixable:
  #
  # class TripRating
  #   include DataMapper::Resource
  #   property :id, Serial
  #   property :trip_id, Integer, :nullable => false
  #   property :user_id, Integer, :nullable => false
  #   property :rating,  Integer, :nullable => false
  #
  #   belongs_to :user
  # end
  #
  # allowing the following options:
  #
  # options = {
  #  :rater => { :name => :user_id, :type => Integer },
  #  :allowed_ratings => (0..5),
  #  :timestamps => true,
  #  :as => nil,                     # if symbol/string then add an alias by that name on has n, :ratings
  #  :class_name => "#{self}Rating"  # class_name to use for generated remixed model
  # }
  
  is :rateable #, options
  
end

About

Add the possibility to rate any DataMapper::Resource by remixing a Rating module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages