module ActsAsCommentableMore::Helpers::Post::AssociationsHelper

Private Instance Methods

define_based_inflection_4(commantable_name, association_comment_name) click to toggle source
# File lib/acts_as_commentable_more/helpers/post/associations_helper.rb, line 13
def define_based_inflection_4(commantable_name, association_comment_name)
  order_by_attrs = aacm_association_options[:order_by]
  association_options = aacm_association_options.except(:order_by)
  has_many "#{association_comment_name}".to_sym,
           -> { order(order_by_attrs) },
           association_options
end
define_role_based_inflection_3(role, commantable_name, association_comment_name) click to toggle source
# File lib/acts_as_commentable_more/helpers/post/associations_helper.rb, line 28
def define_role_based_inflection_3(role, commantable_name, association_comment_name)
  has_many "#{association_comment_name}".to_sym,
           has_many_options(role).merge(:conditions => { role: role })
end
define_role_based_inflection_4(role, commantable_name, association_comment_name) click to toggle source
# File lib/acts_as_commentable_more/helpers/post/associations_helper.rb, line 33
def define_role_based_inflection_4(role, commantable_name, association_comment_name)
  order_by_attrs = aacm_association_options[:order_by]
  has_many "#{association_comment_name}".to_sym,
           -> { where(role: role).order(order_by_attrs) },
           has_many_options(role)
end
has_many_options(role) click to toggle source
# File lib/acts_as_commentable_more/helpers/post/associations_helper.rb, line 40
def has_many_options(role)
  association_options = aacm_association_options.except(:order_by)
  { before_add: Proc.new { |post, comment| comment.role = role } }.merge(association_options)
end
post_define_based_inflection(association_comment_name) click to toggle source
# File lib/acts_as_commentable_more/helpers/post/associations_helper.rb, line 8
def post_define_based_inflection(association_comment_name)
  commantable_name = aacm_association_options[:as].to_sym
  send("define_based_inflection_#{Rails.version.first}", commantable_name, association_comment_name)
end
post_define_role_based_inflection(role, association_comment_name) click to toggle source
# File lib/acts_as_commentable_more/helpers/post/associations_helper.rb, line 23
def post_define_role_based_inflection(role, association_comment_name)
  commantable_name = aacm_association_options[:as].to_sym
  send("define_role_based_inflection_#{Rails.version.first}", role, commantable_name, association_comment_name)
end