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
-
#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 |
# 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 end |
Instance Attribute Details
#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
30 31 32 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 30 def assumed_quota @assumed_quota ||= encoding_quota.assume(files: files) end |
#exceeding? ⇒ Boolean
15 16 17 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 15 def exceeding? assumed_quota.exceeded? end |
#files ⇒ Object
34 35 36 37 38 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 34 def files @files ||= entry.video_files.find(attributes.fetch(:video_file_ids, [])) + entry.audio_files.find(attributes.fetch(:audio_file_ids, [])) end |
#save! ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/pageflow/encoding_confirmation.rb', line 19 def save! ActiveRecord::Base.transaction do raise(QuotaExceededError) if exceeding? files.each do |file| file.confirmed_by = user file.confirm_encoding! end end end |