Sha256: 00d741c5c9ececdd8c9caaf94b938325b82d909419d696ee14f65f4531a2cc3f

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 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={}, &block)
      add_resource(:call_function, opts.merge({:str => str, :name => str.keyerize}), &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

6 entries across 6 versions & 2 rubygems

Version Path
auser-poolparty-1.1.1 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-1.1.3 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-1.1.4 lib/poolparty/poolparty/custom_resource.rb
auser-poolparty-1.1.5 lib/poolparty/poolparty/custom_resource.rb
fairchild-poolparty-1.1.3 lib/poolparty/poolparty/custom_resource.rb
fairchild-poolparty-1.1.4 lib/poolparty/poolparty/custom_resource.rb