Class: Attach::AttachmentDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/attach/attachment_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AttachmentDSL

Returns a new instance of AttachmentDSL.



8
9
10
11
12
# File 'lib/attach/attachment_dsl.rb', line 8

def initialize(&block)
  @processors = []
  @validators = []
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#processorsObject (readonly)

Returns the value of attribute processors.



6
7
8
# File 'lib/attach/attachment_dsl.rb', line 6

def processors
  @processors
end

#validatorsObject (readonly)

Returns the value of attribute validators.



6
7
8
# File 'lib/attach/attachment_dsl.rb', line 6

def validators
  @validators
end

Instance Method Details

#processor(*processors, &block) ⇒ Object



14
15
16
17
# File 'lib/attach/attachment_dsl.rb', line 14

def processor(*processors, &block)
  processors.each { |p| @processors << p }
  @processors << block if block_given?
end

#validator(*validators, &block) ⇒ Object



19
20
21
22
# File 'lib/attach/attachment_dsl.rb', line 19

def validator(*validators, &block)
  validators.each { |v| @validators << v }
  @validators << block if block_given?
end