Sha256: 5f27c87c280f20a3d77aaa9daa90bc311dc90e979a94152a1627fd78b1b509c9

Contents?: true

Size: 1.49 KB

Versions: 41

Compression:

Stored size: 1.49 KB

Contents

require File.dirname(__FILE__) + "/resource"

module PoolParty
  def available_custom_resources
    $available_custom_resources ||= []
  end
  module DefinableFact
    def define_fact(name, string="")
      
    end
  end

  module Resources
    
    def call_function(str, opts={}, &block)
      returning PoolParty::Resources::CallFunction.new(str, opts, &block) do |o|
        resource(:call_function) << o
      end
    end
                
    # Resources for function call
    class CallFunction < Resource
      def initialize(str="", opts={}, parent=self, &block)
        @str = str
        # super(opts, parent, &block)
      end
      def to_string(pre="")
        returning Array.new do |arr|
          arr << "#{pre}#{@str}"
        end.join("\n")
      end
    end
        
    class CustomResource < Resource
      def initialize(name=:custom_method, opts={}, parent=self, &block)
        @name = name
        super(opts, parent, &block)
      end
      
      def self.inherited(subclass)
        PoolParty::Resources.available_custom_resources << subclass
        super(subclass)
      end
      
      def to_string(pre="")
        returning Array.new do |output|
          output << "#{pre} # Custom Functions\n"
          output << self.class.custom_functions_to_string(pre)
        end.join("\n")        
      end
    end
    
    # Stub methods
    # TODO: Find a better solution
    def custom_function(*args, &block)
    end
    def self.custom_function(*args, &block)
    end      
    
  end    
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
auser-poolparty-0.2.15 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.16 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.20 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.21 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.22 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.23 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.24 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.25 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.26 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.35 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.36 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.37 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.38 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.39 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.40 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.41 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.42 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.44 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.45 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.46 lib/poolparty/pool/custom_resource.rb