Class: PoolParty::Resources::File
- Inherits:
-
Resource
- Object
- PoolPartyBaseClass
- Resource
- PoolParty::Resources::File
- Defined in:
- lib/poolparty/resources/file.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #absent ⇒ Object
- #after_create ⇒ Object
- #loaded(o = {}, &block) ⇒ Object
- #method_missing(m, *a, &block) ⇒ Object
- #present ⇒ Object
Methods inherited from Resource
available_resources, #class_name_sym, #class_type_name, #cloud, #custom_function, custom_function, custom_functions, custom_functions_to_string, #disallowed_options, #duplicatable?, #get_modified_options, inherited, #initialize, #is_a_resource?, #is_in_plugin?, #key, #name, #resource?, #resource_name, #services
Methods included from PoolParty::ResourcingDsl
#cancel, #cancelled?, #client_template_exists?, #client_templates_directory_exists?, #ensures, #get_client_or_gem_template, #ifnot, #is_absent, #is_present, #on_change, #printed, #printed?, #render_template, #requires
Methods included from DependencyResolverResourceExtensions
Methods inherited from PoolPartyBaseClass
add_has_and_does_not_have_methods_for, #add_resource, #add_service, #add_to_parent_if_parent_exists_and_is_a_service, #get_local_resource, #get_name_from_options_and_extra_options, #get_resource, #handle_option_values, #in_local_resources?, #initialize, #is_a_resource?, #is_plugin?, #ordered_resources, #plugin_store, #resource, #resources, #run_in_context, #services, #store_in_local_resources
Methods included from DependencyResolverCloudExtensions
Constructor Details
This class inherits a constructor from PoolParty::Resources::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &block) ⇒ Object
38 39 40 |
# File 'lib/poolparty/resources/file.rb', line 38 def method_missing m, *a, &block super rescue ::File.send(m, *a, &block) end |
Instance Method Details
#absent ⇒ Object
14 15 16 |
# File 'lib/poolparty/resources/file.rb', line 14 def absent :delete end |
#after_create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/poolparty/resources/file.rb', line 18 def after_create run_render = .include?(:render_as) ? .delete(:render_as) : false if .include?(:template) filename = ::File.(.template) .delete(:template) file = ::File.basename( filename ) raise TemplateNotFound.new("no template given") unless file template_opts = (parent ? .merge(parent.) : ) .merge!(:content => run_render ? Template.compile_file(filename, template_opts.merge(:renderer => run_render)).gsub("\"", "\"") : open(filename).read) end if .include?(:content) cont = .delete(:content) template_opts = (parent ? .merge(parent.) : ).merge(:renderer => run_render) .merge!(:content => run_render ? Template.compile_string(cont, template_opts) : cont) end end |
#loaded(o = {}, &block) ⇒ Object
6 7 8 |
# File 'lib/poolparty/resources/file.rb', line 6 def loaded(o={}, &block) parent.has_directory ::File.dirname(name) if parent end |
#present ⇒ Object
10 11 12 |
# File 'lib/poolparty/resources/file.rb', line 10 def present :create end |