Class: Code
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Code
- Includes:
- HasOwner
- Defined in:
- app/models/code.rb
Overview
Code for user
Attributes:
- agent_id [Agent], optional
- body [String]
- code_type_id [CodeType]
- created_at [DateTime]
- ip [Inet]
- payload [String], optional
- quantity [Integer]
- updated_at [DateTime]
- user_id [User], optional
Constant Summary collapse
- BODY_LIMIT =
50
- PAYLOAD_LIMIT =
255
- QUANTITY_RANGE =
(0..32_767).freeze
Class Method Summary collapse
- .creation_parameters ⇒ Object
- .entity_parameters ⇒ Object
- .page_for_administration(page = 1) ⇒ Object
Instance Method Summary collapse
Methods included from HasOwner
Class Method Details
.creation_parameters ⇒ Object
48 49 50 |
# File 'app/models/code.rb', line 48 def self.creation_parameters entity_parameters + %i[user_id code_type_id] end |
.entity_parameters ⇒ Object
44 45 46 |
# File 'app/models/code.rb', line 44 def self.entity_parameters %i[body payload quantity] end |
.page_for_administration(page = 1) ⇒ Object
40 41 42 |
# File 'app/models/code.rb', line 40 def self.page_for_administration(page = 1) list_for_administration.page(page) end |
Instance Method Details
#activated? ⇒ Boolean
52 53 54 |
# File 'app/models/code.rb', line 52 def activated? quantity < 1 end |
#active? ⇒ Boolean
56 57 58 |
# File 'app/models/code.rb', line 56 def active? quantity.positive? end |