Class: Code
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Code
- Defined in:
- app/models/code.rb
Overview
Code for users
Attributes:
agent_id [Agent], optional
biovision_component_id [BiovisionComponent]
body [string]
created_at [DateTime]
data [jsonb]
ip_address_id [IpAddress], optional
quantity [integer]
updated_at [DateTime]
user_id [User]
Constant Summary collapse
- BODY_LIMIT =
50
- QUANTITY_RANGE =
(0..32_767)
Class Method Summary collapse
- .creation_parameters ⇒ Object
- .entity_parameters ⇒ Object
- .page_for_administration(page = 1) ⇒ Object
Instance Method Summary collapse
- #activated? ⇒ Boolean
- #active? ⇒ Boolean
- #code_type ⇒ Object
- #code_type=(new_type) ⇒ Object
- #phone? ⇒ Boolean
- #type?(type_name) ⇒ Boolean
Methods included from HasOwner
Class Method Details
.creation_parameters ⇒ Object
47 48 49 |
# File 'app/models/code.rb', line 47 def self.creation_parameters entity_parameters + %i[user_id biovision_component_id] end |
.entity_parameters ⇒ Object
43 44 45 |
# File 'app/models/code.rb', line 43 def self.entity_parameters %i[body quantity] end |
.page_for_administration(page = 1) ⇒ Object
39 40 41 |
# File 'app/models/code.rb', line 39 def self.page_for_administration(page = 1) list_for_administration.page(page) end |
Instance Method Details
#activated? ⇒ Boolean
51 52 53 |
# File 'app/models/code.rb', line 51 def activated? quantity < 1 end |
#active? ⇒ Boolean
55 56 57 |
# File 'app/models/code.rb', line 55 def active? quantity.positive? end |
#code_type ⇒ Object
64 65 66 |
# File 'app/models/code.rb', line 64 def code_type data['type'].to_s end |
#code_type=(new_type) ⇒ Object
69 70 71 |
# File 'app/models/code.rb', line 69 def code_type=(new_type) data['type'] = new_type.to_s end |
#phone? ⇒ Boolean
73 74 75 |
# File 'app/models/code.rb', line 73 def phone? type?(Biovision::Components::UsersComponent::CODE_PHONE_CONFIRMATION) end |
#type?(type_name) ⇒ Boolean
60 61 62 |
# File 'app/models/code.rb', line 60 def type?(type_name) code_type == type_name.to_s end |