Sha256: 500b63a8a5c796846bbaa00e6b1c3d1ae0e1f6e370cac5978bdaf1f00b01ee00

Contents?: true

Size: 322 Bytes

Versions: 3

Compression:

Stored size: 322 Bytes

Contents

# frozen_string_literal: true

module Talkie
  class Permission < Struct.new(:user)
    def allow?(action, comment)
      action = action.to_s

      if user
        return true if action.in? %w[create]
        return true if user.owns_comment?(comment) && action.in?(%w[destroy])
      end

      false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
talkie-0.2.0 lib/talkie/permission.rb
talkie-0.1.1 lib/talkie/permission.rb
talkie-0.1.0 lib/talkie/permission.rb