Class: Temper::Base
- Inherits:
-
Object
- Object
- Temper::Base
- Defined in:
- lib/temper/base.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#original_filename ⇒ Object
Returns the value of attribute original_filename.
Instance Method Summary collapse
- #close ⇒ Object
- #fingerprint ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#method_missing(method_name, *args, &block) ⇒ Object
:nodoc:.
- #respond_to?(*args) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/temper/base.rb', line 6 def initialize( = {}) raise RuntimeException, "No @storage set" unless @storage self.original_filename = [:original_filename] || ::File.basename(path) self.content_type = [:content_type] || infer_content_type || "text/plain" if block_given? begin yield self ensure close end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
:nodoc:
32 33 34 |
# File 'lib/temper/base.rb', line 32 def method_missing(method_name, *args, &block) #:nodoc: @storage.__send__(method_name, *args, &block) end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
4 5 6 |
# File 'lib/temper/base.rb', line 4 def content_type @content_type end |
#original_filename ⇒ Object
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
#close ⇒ Object
20 21 22 |
# File 'lib/temper/base.rb', line 20 def close #noop end |
#fingerprint ⇒ Object
24 25 26 |
# File 'lib/temper/base.rb', line 24 def fingerprint @fingerprint ||= Digest::MD5.hexdigest(self.read) end |
#respond_to?(*args) ⇒ Boolean
28 29 30 |
# File 'lib/temper/base.rb', line 28 def respond_to?(*args) super or @storage.respond_to?(*args) end |