Class: Temper::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/temper/base.rb

Direct Known Subclasses

File, StringIO

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.

Raises:

  • (RuntimeException)


6
7
8
9
10
# File 'lib/temper/base.rb', line 6

def initialize(options = {})
  raise RuntimeException, "No @storage set" unless @storage
  self.original_filename = options[:original_filename] || ::File.basename(path)
  self.content_type = options[:content_type] || infer_content_type || "text/plain"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

:nodoc:



20
21
22
# File 'lib/temper/base.rb', line 20

def method_missing(method_name, *args, &block) #:nodoc:
  @storage.__send__(method_name, *args, &block)
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



4
5
6
# File 'lib/temper/base.rb', line 4

def content_type
  @content_type
end

#original_filenameObject

Returns the value of attribute original_filename.



3
4
5
# File 'lib/temper/base.rb', line 3

def original_filename
  @original_filename
end

Instance Method Details

#fingerprintObject



12
13
14
# File 'lib/temper/base.rb', line 12

def fingerprint
  @fingerprint ||= Digest::MD5.hexdigest(self.read)
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/temper/base.rb', line 16

def respond_to?(*args)
  super or @storage.respond_to?(*args)
end