Module: ActsPermissive::PermissiveObject::ActiveResourceSafeMethods

Defined in:
lib/acts_permissive/permissive_object.rb

Instance Method Summary collapse

Instance Method Details

#add_to(*args) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/acts_permissive/permissive_object.rb', line 83

def add_to *args
  args.each do |arg|
    ActsPermissive::Circling.create! :circleable_id => self.id,
                     :circleable_type => self.class.name,
                     :circle_id => arg.id
  end
end

#circlesObject



79
80
81
# File 'lib/acts_permissive/permissive_object.rb', line 79

def circles
  ActsPermissive::Circle.find circlings.map{|i| i.circle_id}
end

#circlingsObject



74
75
76
77
# File 'lib/acts_permissive/permissive_object.rb', line 74

def circlings
  ActsPermissive::Circling.all :conditions => {:circleable_id => self.id,
                                               :circleable_type => self.class.name}
end

#remove_from(*args) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/acts_permissive/permissive_object.rb', line 91

def remove_from *args
  args.each do |arg|
    raise "Must be a circle" if arg.class != Circle
    ActsPermissive::Circling.first(:conditions => {
                            :circle_id => arg.id,
                            :circleable_id => self.id,
                            :circleable_type => self.class.name}).destroy
  end
end