Module: Popular::Popular::ClassMethods

Defined in:
lib/popular/popular.rb

Overview

ClassMethods included in popular models

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#friendship_profileObject

Returns the value of attribute friendship_profile.



152
153
154
# File 'lib/popular/popular.rb', line 152

def friendship_profile
  @friendship_profile
end

Instance Method Details

#after_befriend(*args, &blk) ⇒ Object

after_befriend callback convenience class method Fired after a popular_model befriends another popular_model

Examples:


class User < ActiveRecord::Base
  popular
  after_befriend :do_something_amazing

  def do_something_amazing
    puts name
  end
end

user = User.create name: "Justin"
another_user = User.create name: "Jenny"

user.befriend another_user #=> "Justin"


240
241
242
# File 'lib/popular/popular.rb', line 240

def after_befriend *args, &blk
  set_callback :befriend, :after, *args, &blk
end

#after_unfriend(*args, &blk) ⇒ Object

after_unfriend callback convenience class method Fired after a popular_model unfriends another popular_model

Examples:


class User < ActiveRecord::Base
  popular
  after_unfriend :do_something_amazing

  def do_something_amazing
    puts name
  end
end

user = User.create name: "Justin"
another_user = User.create name: "Jenny"

user.befriend another_user
user.unfriend another_user #=> "Justin"


173
174
175
# File 'lib/popular/popular.rb', line 173

def after_unfriend *args, &blk
  set_callback :unfriend, :after, *args, &blk
end

#before_befriend(*args, &blk) ⇒ Object

before_befriend callback convenience class method Fired before a popular model befriends another popular_model

Examples:


class User < ActiveRecord::Base
  popular
  before_befriend :do_something_amazing

  def do_something_amazing
    puts name
  end
end

user = User.create name: "Justin"
another_user = User.create name: "Jenny"

user.befriend another_user #=> "Justin"


218
219
220
# File 'lib/popular/popular.rb', line 218

def before_befriend *args, &blk
  set_callback :befriend, :before, *args, &blk
end

#before_unfriend(*args, &blk) ⇒ Object

before_unfriend callback convenience class method Fired before a popular_model unfriends another popular_model

Examples:


class User < ActiveRecord::Base
  popular
  before_unfriend :do_something_amazing

  def do_something_amazing
    puts name
  end
end

user = User.create name: "Justin"
another_user = User.create name: "Jenny"

user.befriend another_user
user.unfriend another_user #=> "Justin"


196
197
198
# File 'lib/popular/popular.rb', line 196

def before_unfriend *args, &blk
  set_callback :unfriend, :before, *args, &blk
end