Class: Nanoc3::Extra::FileProxy Deprecated
- Inherits:
-
Object
- Object
- Nanoc3::Extra::FileProxy
- Defined in:
- lib/nanoc3/extra/file_proxy.rb
Overview
Deprecated.
Create a File instance directly and use that instead.
Constant Summary collapse
- @@deprecation_warning_shown =
false
Instance Method Summary collapse
- #freeze ⇒ Object
-
#initialize(path) ⇒ FileProxy
constructor
A new instance of FileProxy.
- #method_missing(sym, *args, &block) ⇒ Object
- #respond_to?(meth) ⇒ Boolean
Constructor Details
#initialize(path) ⇒ FileProxy
Returns a new instance of FileProxy.
12 13 14 |
# File 'lib/nanoc3/extra/file_proxy.rb', line 12 def initialize(path) @path = path end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/nanoc3/extra/file_proxy.rb', line 23 def method_missing(sym, *args, &block) if !@@deprecation_warning_shown $stderr.puts 'WARNING: The :file attribute is deprecated and will be removed in a future version of nanoc. Instead of using this :file attribute, consider manually creating a File object when it’s needed, using the :content_filename, :meta_filename or :filename attributes.' @@deprecation_warning_shown = true end File.open(@path, 'r') { |io| io.__send__(sym, *args, &block) } end |
Instance Method Details
#freeze ⇒ Object
16 17 |
# File 'lib/nanoc3/extra/file_proxy.rb', line 16 def freeze end |
#respond_to?(meth) ⇒ Boolean
19 20 21 |
# File 'lib/nanoc3/extra/file_proxy.rb', line 19 def respond_to?(meth) file_instance_methods.include?(meth.to_sym) end |