Module: MasterView::MIO::MasterViewIOTreeMixin
- Included in:
- ActiveRecordMIOTree, FileMIOTree, StringHashMIOTree
- Defined in:
- lib/masterview/io.rb
Overview
mixin which encapsulates the apply filter to new MIO objects and the default filter block
Constant Summary collapse
- DefaultExtensionInstances =
{}
Instance Method Summary collapse
-
#apply_filters(mio, options, block) ⇒ Object
apply filters to object, use block if provided otherwise use default_mio_filter_block which is customized by options hash options = true enables erb escaping options = true enables tidy processing to cleanup bad xhtml options = true enables caching so that reads are cached options = true enables logging of reads and writes options = true enables creation of default generate directive if none found.
-
#cleanup_path_get_relative_pathname(path) ⇒ Object
clean up ../..
- #default_extension ⇒ Object
- #default_extension=(default_extension) ⇒ Object
- #default_mio_filter_block(options) ⇒ Object
Instance Method Details
#apply_filters(mio, options, block) ⇒ Object
apply filters to object, use block if provided otherwise use default_mio_filter_block which is customized by options hash options = true enables erb escaping options = true enables tidy processing to cleanup bad xhtml options = true enables caching so that reads are cached options = true enables logging of reads and writes options = true enables creation of default generate directive if none found
58 59 60 61 62 63 64 65 |
# File 'lib/masterview/io.rb', line 58 def apply_filters(mio, , block) if block block.call(mio) else default_mio_filter_block().call(mio) end mio end |
#cleanup_path_get_relative_pathname(path) ⇒ Object
clean up ../.. check if path starts with root path and if so get relative, otherwise return path, root_path is only used in FileMIO, so all others just simply clean the path. FileMIO will override this with its own implementation.
87 88 89 90 91 |
# File 'lib/masterview/io.rb', line 87 def cleanup_path_get_relative_pathname(path) pathname = Pathname.for_path(path) pathname = Pathname.for_path(pathname.to_s+self.default_extension) if pathname.extname.empty? && self.default_extension && !self.default_extension.empty? pathname end |
#default_extension ⇒ Object
77 78 79 |
# File 'lib/masterview/io.rb', line 77 def default_extension DefaultExtensionInstances[object_id] end |
#default_extension=(default_extension) ⇒ Object
81 82 83 |
# File 'lib/masterview/io.rb', line 81 def default_extension=(default_extension) DefaultExtensionInstances[object_id] = default_extension end |
#default_mio_filter_block(options) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/masterview/io.rb', line 67 def default_mio_filter_block() lambda do |mio| mio.extend EscapeErbMIOFilter if [:escape_erb] mio.extend TidyMIOFilter if [:tidy] mio.extend DefaultGenerateMIOFilter if [:default_generate] mio.extend CachingMIOFilter if [:caching] mio.extend ReadWriteLoggingMIOFilter if [:logging] end end |