Class: Attach::Processor
- Inherits:
- 
      Object
      
        - Object
- Attach::Processor
 
- Defined in:
- lib/attach/processor.rb
Class Method Summary collapse
- .background(&block) ⇒ Object
- .background_block ⇒ Object
- .processor(model, attribute) ⇒ Object
- .register(model, attribute, &block) ⇒ Object
Instance Method Summary collapse
- 
  
    
      #initialize(attachment)  ⇒ Processor 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Processor. 
- #process ⇒ Object
- #queue_or_process ⇒ Object
Constructor Details
#initialize(attachment) ⇒ Processor
Returns a new instance of Processor.
| 22 23 24 | # File 'lib/attach/processor.rb', line 22 def initialize() @attachment = end | 
Class Method Details
.background(&block) ⇒ Object
| 4 5 6 | # File 'lib/attach/processor.rb', line 4 def self.background(&block) @background_block = block end | 
.background_block ⇒ Object
| 8 9 10 | # File 'lib/attach/processor.rb', line 8 def self.background_block @background_block end | 
.processor(model, attribute) ⇒ Object
| 18 19 20 | # File 'lib/attach/processor.rb', line 18 def self.processor(model, attribute) @processors && @processors[[model.to_s, attribute.to_s]] end | 
.register(model, attribute, &block) ⇒ Object
| 12 13 14 15 16 | # File 'lib/attach/processor.rb', line 12 def self.register(model, attribute, &block) @processors ||= {} @processors[[model.to_s, attribute.to_s]] ||= [] @processors[[model.to_s, attribute.to_s]] = block end | 
Instance Method Details
#process ⇒ Object
| 26 27 28 29 30 | # File 'lib/attach/processor.rb', line 26 def process call_processors(@attachment) @attachment.processed = true @attachment.save(:validate => false) end | 
#queue_or_process ⇒ Object
| 32 33 34 35 36 37 38 | # File 'lib/attach/processor.rb', line 32 def queue_or_process if self.class.background_block self.class.background_block.call(@attachment) else process end end |