Class: Pageflow::EncodingConfirmation
- Inherits:
-
Object
- Object
- Pageflow::EncodingConfirmation
- Defined in:
- app/models/pageflow/encoding_confirmation.rb
Defined Under Namespace
Classes: QuotaExceededError
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#encoding_quota ⇒ Object
readonly
Returns the value of attribute encoding_quota.
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #assumed_quota ⇒ Object
- #exceeding? ⇒ Boolean
- #files ⇒ Object
-
#initialize(entry, attributes, encoding_quota, user) ⇒ EncodingConfirmation
constructor
A new instance of EncodingConfirmation.
- #save! ⇒ Object
Constructor Details
#initialize(entry, attributes, encoding_quota, user) ⇒ EncodingConfirmation
Returns a new instance of EncodingConfirmation.
8 9 10 11 12 13 14 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 8 def initialize(entry, attributes, encoding_quota, user) @entry = entry @attributes = attributes @encoding_quota = encoding_quota @user = user @account = entry.account end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
6 7 8 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 6 def account @account end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 6 def attributes @attributes end |
#encoding_quota ⇒ Object (readonly)
Returns the value of attribute encoding_quota.
6 7 8 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 6 def encoding_quota @encoding_quota end |
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
6 7 8 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 6 def entry @entry end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 6 def user @user end |
Instance Method Details
#assumed_quota ⇒ Object
31 32 33 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 31 def assumed_quota @assumed_quota ||= encoding_quota.assume(files: files) end |
#exceeding? ⇒ Boolean
16 17 18 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 16 def exceeding? assumed_quota.exceeded? end |
#files ⇒ Object
35 36 37 38 39 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 35 def files @files ||= entry.video_files.find(attributes.fetch(:video_file_ids, [])) + entry.audio_files.find(attributes.fetch(:audio_file_ids, [])) end |
#save! ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 20 def save! ActiveRecord::Base.transaction do raise(QuotaExceededError) if exceeding? files.each do |file| file.confirmed_by = user file.confirm_encoding! end end end |