Class: Agent

Inherits:
ApplicationRecord
  • Object
show all
Includes:
RequiredUniqueName, Toggleable
Defined in:
app/models/agent.rb

Overview

User agent

Attributes:

banned [boolean]
browser_id [Browser], optional
created_at [DateTime]
object_count [integer]
name [string]
updated_at [DateTime]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Parameters:

  • name (String)


30
31
32
33
34
# File 'app/models/agent.rb', line 30

def self.[](name)
  return if name.blank?

  find_or_create_by(name: name[0..254])
end

.page_for_administration(page = 1) ⇒ Object

Parameters:

  • page (Integer) (defaults to: 1)


25
26
27
# File 'app/models/agent.rb', line 25

def self.page_for_administration(page = 1)
  list_for_administration.page(page)
end

Instance Method Details

#bot?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/agent.rb', line 36

def bot?
  name.downcase.include?('bot')
end