Module: Interest::Blockable::Blocker::ClassMethods

Defined in:
lib/interest/blockable/blocker.rb

Instance Method Summary collapse

Instance Method Details

#define_blocker_association_method(source_type) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/interest/blockable/blocker.rb', line 57

def define_blocker_association_method(source_type)
  association_method_name = blocker_association_method_name_for source_type

  has_many association_method_name,
    -> { uniq },
    through:     :blocking_relationships,
    source:      :blockee,
    source_type: source_type
end

#define_blocker_association_methodsObject



47
48
49
50
51
52
53
54
55
# File 'lib/interest/blockable/blocker.rb', line 47

def define_blocker_association_methods
  has_many :blocking_relationships,
    -> { uniq },
    as:          :blocker,
    dependent:   :destroy,
    class_name:  Interest.blocking_class_name do
      include Interest::Definition.collection_methods_for(:blockee)
    end
end