Class: PoolParty::Service

Inherits:
PoolPartyBaseClass show all
Includes:
DependencyResolverCloudExtensions
Defined in:
lib/poolparty/poolparty/service.rb

Direct Known Subclasses

Plugin::Plugin

Instance Attribute Summary

Attributes inherited from PoolPartyBaseClass

#init_opts, #ordered_resources

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PoolPartyBaseClass

#add_resource, add_resource_lookup_method, #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, #inspect, #is_a_resource?, #is_plugin?, #plugin_store, #resource, #resources, #run_in_context, #run_with_callbacks, #search_in_known_locations, #store_in_local_resources, #to_hash, #to_json

Methods included from SearchablePaths

included

Constructor Details

This class inherits a constructor from PoolParty::PoolPartyBaseClass

Class Method Details

.add_has_and_does_not_have_methods_for(typ = :file) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/poolparty/poolparty/service.rb', line 20

def self.add_has_and_does_not_have_methods_for(typ=:file)      
  meth = <<-EOM
    def __#{typ}(opts={}, &block)
      i = ::PoolParty::Plugin::#{typ.camelcase}.new(opts, &block)
      plugin_store << i if respond_to?(:plugin_store)
      i
    end
    alias :#{typ} :__#{typ}
  EOM
  
  PoolParty::PoolPartyBaseClass.module_eval meth
  PoolParty::PoolPartyBaseClass.add_has_and_does_not_have_methods_for(typ.to_sym)
end

Instance Method Details

#cloudObject



13
14
15
16
17
18
# File 'lib/poolparty/poolparty/service.rb', line 13

def cloud
  2.upto(context_stack.size) do |i|
    return ::PoolParty.context_stack[-i] if ::PoolParty.context_stack[-i].is_a?(PoolParty::Cloud::Cloud)
  end
  nil
end

#to_properties_hashObject



7
8
9
10
11
# File 'lib/poolparty/poolparty/service.rb', line 7

def to_properties_hash
  { :pp_type => "plugin", :options => dsl_options, 
    :name => (dsl_options[:name] ? dsl_options[:name] : self.class.to_s.split('::').pop.snake_case),
    :resources => ordered_resources.map {|a| a.to_properties_hash }}
end