Class/Module Index [+]

Quicksearch

FeedTools::GenericHelper

Generic methods needed in numerous places throughout FeedTools

Public Class Methods

recursion_trap(lock_object, &block) click to toggle source

Nifty little method that takes a block and returns nil if recursion occurs or the block's result value if it doesn't.

# File lib/feed_tools/helpers/generic_helper.rb, line 40
def self.recursion_trap(lock_object, &block)
  if @lock_ids.nil?
    @lock_ids = []
  end
  if !@lock_ids.include?(lock_object.object_id)
    @lock_ids << lock_object.object_id
  else
    return nil
  end
  begin
    result = block.call
  rescue SystemStackError
    result = nil
  end
  @lock_ids.delete(lock_object.object_id)
  return result
end
validate_options(valid_option_keys, supplied_option_keys) click to toggle source

Raises an exception if an invalid option has been specified to prevent misspellings from slipping through

# File lib/feed_tools/helpers/generic_helper.rb, line 31
def self.validate_options(valid_option_keys, supplied_option_keys)
  unknown_option_keys = supplied_option_keys - valid_option_keys
  unless unknown_option_keys.empty?
    raise "Unknown options: #{unknown_option_keys}"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.