Sha256: 32cc7682da4ca2e93b5666d6c10ab96b86dfe81746aeb8b9404c74e5d3f24cf2

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

module Sow

  FIX = "FIXME"

  # Erb templates are all rendered within the scope
  # a context object. This limits access to only
  # the those things that are pertinant. All metadata
  # can be accessded by name, as this this object
  # delegate missing methods to a Metadata instance.
  #
  class Context
    instance_methods.each{ |m| private m unless m.to_s =~ /^__/ }

    def initialize(metadata)
      @metadata = metadata
    end

    def method_missing(s)
      @metadata.__send__(s) || "#{FIX}: (#{s})"
    end

    # Processes file through erb.
    def erb(file)
      erb = ERB.new(File.read(file))
      erb.result(binding)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sow-0.5 lib/sow/context.rb
sow-0.4.0 lib/sow/context.rb