class AccessGrant

def accessible?

def accessible?
  !expired? && !revoked?
end

def expired?

def expired?
  expires_in.present? && Time.now > expired_time
end

def expired_time

def expired_time
  self.created_at + expires_in.seconds
end

def generate_token

def generate_token
  self.token = unique_random_string_for(:token)
end

def revoke

def revoke
  update_attribute :revoked_at, DateTime.now
end

def revoked?

def revoked?
  revoked_at.present?
end

def scopes

def scopes
  self[:scopes].split(" ").map(&:to_sym)
end

def scopes_string

def scopes_string
  self[:scopes]
end