Module: Interest::Blockable::Blocking
- Extended by:
- ActiveSupport::Concern
- Included in:
- Blocking
- Defined in:
- lib/interest/blockable/blocking.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #destroy_following_relationships ⇒ Object
- #should_validate_blocking_relationships? ⇒ Boolean
- #validate_blocking_relationships ⇒ Object
Instance Method Details
#destroy_following_relationships ⇒ Object
27 28 29 |
# File 'lib/interest/blockable/blocking.rb', line 27 def destroy_following_relationships Interest.following_class.destroy_relationships_between blocker, blockee end |
#should_validate_blocking_relationships? ⇒ Boolean
31 32 33 |
# File 'lib/interest/blockable/blocking.rb', line 31 def should_validate_blocking_relationships? blocker.is_a?(ActiveRecord::Base) and blockee.is_a?(ActiveRecord::Base) end |
#validate_blocking_relationships ⇒ Object
35 36 37 38 39 |
# File 'lib/interest/blockable/blocking.rb', line 35 def validate_blocking_relationships errors.add :blocker, :invalid unless blocker.blocker? errors.add :blockee, :invalid unless blockee.blockee? errors.add :blockee, :rejected if blocker.blocker? and not blocker.valid_blocking_for?(blockee) end |