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
- @@deprecation_warning_shown =
false
Instance Method Summary (collapse)
-
- (FileProxy) initialize(path)
constructor
A new instance of FileProxy.
- - (Object) method_missing(sym, *args, &block)
- - (Boolean) respond_to?(meth)
Constructor Details
- (FileProxy) initialize(path)
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
- (Object) method_missing(sym, *args, &block)
20 21 22 23 24 25 26 27 |
# File 'lib/nanoc3/extra/file_proxy.rb', line 20 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
- (Boolean) respond_to?(meth)
16 17 18 |
# File 'lib/nanoc3/extra/file_proxy.rb', line 16 def respond_to?(meth) File.instance_methods.any? { |m| m == meth.to_s || m == meth.to_sym } end |