module Notably::Notification::ClassMethods

Attributes

callbacks[R]

Public Class Methods

extended(base) click to toggle source
# File lib/notably/notification.rb, line 125
def self.extended(base)
  base.class_eval do
    @callbacks = {after_notify: [], before_notify: []}
    @group_by = []
    @group_within = ->(receiver) { receiver.last_notification_read_at }
    @required_attributes = []
  end
end

Public Instance Methods

after_notify(method=nil, &block) click to toggle source
# File lib/notably/notification.rb, line 170
def after_notify(method=nil, &block)
  @callbacks[:after_notify] << (block || method)
end
before_notify(method=nil, &block) click to toggle source
# File lib/notably/notification.rb, line 166
def before_notify(method=nil, &block)
  @callbacks[:before_notify] << (block || method)
end
create(attributes={}) click to toggle source
# File lib/notably/notification.rb, line 134
def create(attributes={})
  new(attributes).save
end
group?() click to toggle source
# File lib/notably/notification.rb, line 154
def group?
  @group_by.any?
end
group_by(*args) click to toggle source
# File lib/notably/notification.rb, line 146
def group_by(*args)
  if args.any?
    @group_by += args
  else
    @group_by
  end
end
group_within(block=nil) click to toggle source
# File lib/notably/notification.rb, line 158
def group_within(block=nil)
  if block
    @group_within = block
  else
    @group_within
  end
end
required_attributes(*args) click to toggle source
# File lib/notably/notification.rb, line 138
def required_attributes(*args)
  if args.any?
    @required_attributes += args
  else
    @required_attributes
  end
end