class AwsEc2::Template::Context

Public Class Methods

new(options={}) click to toggle source
# File lib/aws_ec2/template/context.rb, line 9
def initialize(options={})
  @options = options
  load_custom_helpers
end

Private Instance Methods

load_custom_helpers() click to toggle source

Load custom helper methods from project

# File lib/aws_ec2/template/context.rb, line 16
def load_custom_helpers
  Dir.glob("#{AwsEc2.root}/app/helpers/**/*_helper.rb").each do |path|
    filename = path.sub(%r{.*/},'').sub('.rb','')
    module_name = filename.classify

    # Prepend a period so require works AWS_EC2_ROOT is set to a relative path
    # without a period.
    #
    # Example: AWS_EC2_ROOT=tmp/project
    first_char = path[0..0]
    path = "./#{path}" unless %w[. /].include?(first_char)
    require path
    self.class.send :include, module_name.constantize
  end
end