Class: UnderConstructionEmailStorage
- Inherits:
-
Object
- Object
- UnderConstructionEmailStorage
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- app/models/under_construction_email_storage.rb
Defined Under Namespace
Classes: UniquenessValidator
Constant Summary collapse
- FILE_PATH =
Rails.root + "db/under_construction_mails.txt"
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
Class Method Summary collapse
-
.emails ⇒ Object
return emails in a array.
- .no_emails? ⇒ Boolean
- .remove_file ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ UnderConstructionEmailStorage
constructor
A new instance of UnderConstructionEmailStorage.
- #persisted? ⇒ Boolean
-
#save_to_file ⇒ Object
save submitted mail to a text file.
Constructor Details
#initialize(attributes = {}) ⇒ UnderConstructionEmailStorage
Returns a new instance of UnderConstructionEmailStorage.
26 27 28 29 30 |
# File 'app/models/under_construction_email_storage.rb', line 26 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'app/models/under_construction_email_storage.rb', line 6 def email @email end |
Class Method Details
.emails ⇒ Object
return emails in a array
44 45 46 47 48 49 50 |
# File 'app/models/under_construction_email_storage.rb', line 44 def self.emails File.open(FILE_PATH, "r") do |f| f.readlines end rescue Errno::ENOENT [] end |
.no_emails? ⇒ Boolean
52 53 54 |
# File 'app/models/under_construction_email_storage.rb', line 52 def self.no_emails? emails.empty? end |
Instance Method Details
#persisted? ⇒ Boolean
32 33 34 |
# File 'app/models/under_construction_email_storage.rb', line 32 def persisted? false end |
#save_to_file ⇒ Object
save submitted mail to a text file
37 38 39 40 41 |
# File 'app/models/under_construction_email_storage.rb', line 37 def save_to_file File.open(FILE_PATH, "a") do |f| f.puts email end end |