Module: Transcribable::ClassMethods
- Defined in:
- lib/transcribable.rb
Instance Method Summary collapse
-
#assign!(user_id) ⇒ Object
Override this to write your own assigner By default, it picks a random filing that a user has not transcribed.
-
#set_verification_threshhold(lvl = 1) ⇒ Object
The number over which people must agree on every attribute to verify a transcription.
-
#skip_transcription(*args) ⇒ Object
Attributes that are potential reasons to skip a transcription.
- #skip_verification(*args) ⇒ Object
- #skipped_attrs ⇒ Object
- #transcribable(*args) ⇒ Object
- #transcribable?(_attr) ⇒ Boolean
- #verification_threshhold ⇒ Object
Instance Method Details
#assign!(user_id) ⇒ Object
Override this to write your own assigner By default, it picks a random filing that a user has not transcribed. If there’s nothing left for that user to do, it returns nil. This will get slower the more transcriptions you have, so it’ll be a good idea to index the filing_id (or whatever master table foreign key) column in your transcriptions table.
96 97 98 99 100 101 102 103 104 |
# File 'lib/transcribable.rb', line 96 def assign!(user_id) user_transcribed_filings = Transcription.where(:user_id => user_id).map {|q| q["#{self.table_name.downcase.singularize}_id".to_sym] }.uniq filings = self.where(:verified => [nil, false]) if user_transcribed_filings.length > 0 filings = filings.where("id NOT IN (?)", user_transcribed_filings) end pick = rand(filings.length - 1) filings.length > 0 ? filings[pick] : nil end |
#set_verification_threshhold(lvl = 1) ⇒ Object
The number over which people must agree on every attribute to verify a transcription
74 75 76 |
# File 'lib/transcribable.rb', line 74 def set_verification_threshhold(lvl = 1) @@verification_threshhold = lvl end |
#skip_transcription(*args) ⇒ Object
Attributes that are potential reasons to skip a transcription. If enough people agree to skip, the filing will be marked transcribed.
85 86 87 |
# File 'lib/transcribable.rb', line 85 def skip_transcription(*args) @@skippable = args end |
#skip_verification(*args) ⇒ Object
64 65 66 |
# File 'lib/transcribable.rb', line 64 def skip_verification(*args) @@skip_verification = args end |
#skipped_attrs ⇒ Object
68 69 70 |
# File 'lib/transcribable.rb', line 68 def skipped_attrs @@skip_verification end |
#transcribable(*args) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/transcribable.rb', line 53 def transcribable(*args) args.each do |k| self.columns_hash[k.to_s].instance_variable_set("@transcribable", true) end include Transcribable::LocalInstanceMethods end |
#transcribable?(_attr) ⇒ Boolean
60 61 62 |
# File 'lib/transcribable.rb', line 60 def transcribable?(_attr) self.columns_hash[_attr].instance_variable_get("@transcribable") end |
#verification_threshhold ⇒ Object
78 79 80 |
# File 'lib/transcribable.rb', line 78 def verification_threshhold @@verification_threshhold end |