We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
19 lines
475 B
Ruby
19 lines
475 B
Ruby
module Flaggable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_many :flags, as: :flaggable
|
|
scope :flagged, -> { where("flags_count > 0") }
|
|
scope :pending_flag_review, -> { flagged.where(ignored_flag_at: nil, hidden_at: nil) }
|
|
scope :with_ignored_flag, -> { flagged.where.not(ignored_flag_at: nil).where(hidden_at: nil) }
|
|
end
|
|
|
|
def ignored_flag?
|
|
ignored_flag_at.present?
|
|
end
|
|
|
|
def ignore_flag
|
|
update(ignored_flag_at: Time.current)
|
|
end
|
|
end
|