Skip to Content Skip to Search
Methods
C
D
N
V

Class Public methods

new(args = {})

# File app/actions/action/drip_access_manager.rb, line 3
def initialize(args = {})
  @viewable = args.fetch(:viewable)
  @member = args.fetch(:member)
  @now = args.fetch(:now, Time.zone.now).to_i
  @seconds_until_viewable = nil
  @can_view = false
end

Instance Public methods

can_view?()

# File app/actions/action/drip_access_manager.rb, line 11
def can_view?
  return true if is_site_owner
  return false if outside_period?
  return true unless @viewable.days_until_drip

  ask_plannings_for_access if @member
  @can_view
end

days_until_viewable()

# File app/actions/action/drip_access_manager.rb, line 20
def days_until_viewable
  @seconds_until_viewable / 86_400 if @seconds_until_viewable
end

drip_at()

# File app/actions/action/drip_access_manager.rb, line 24
def drip_at
  Time.zone.at(@now.to_i + @seconds_until_viewable) if @seconds_until_viewable
end

viewing_window()

# File app/actions/action/drip_access_manager.rb, line 28
def viewing_window
  return nil if @viewable.drip_start.nil? && @viewable.drip_end.nil? || !outside_period?

  {start: @viewable.drip_start, end: @viewable.drip_end}
end