Sha256: 57541ec832e782f66d16d88be31d74f61732d99ecc197b7e0aadc2c5a57da61c

Contents?: true

Size: 1.13 KB

Versions: 24

Compression:

Stored size: 1.13 KB

Contents

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

module PoolParty
  def available_custom_resources
    $available_custom_resources ||= []
  end

  module Resources
    
    def call_custom_function(str, opts={}, parent=self, &block)
      add_resource(:call_function, opts.merge({:str => str, :name => str.keyerize}), parent, &block)
    end
                
    # Resources for function call
    class CallFunction < Resource
      def to_string(pre="")
        returning Array.new do |arr|
          arr << "#{pre}#{str}"
        end.join("\n")
      end
    end
        
    class CustomResource < Resource
      def self.inherited(subclass)
        PoolParty::Resources.available_custom_resources << subclass
        super
      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

24 entries across 24 versions & 2 rubygems

Version Path
auser-poolparty-0.2.68 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.69 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.70 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.71 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.72 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.74 lib/poolparty/pool/custom_resource.rb
auser-poolparty-0.2.76 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.77 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.78 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.79 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.80 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.81 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.84 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.85 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.88 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.89 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.90 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.91 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.92 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-0.2.93 lib/poolparty/poolparty/custom_resource.rb