Sha256: e6a1d8da8304b7e723c3e97375b4bac07205a521cea93e3dfff39a6805dc471b

Contents?: true

Size: 751 Bytes

Versions: 15

Compression:

Stored size: 751 Bytes

Contents

module Erector
  class Dependency
    attr_reader :type, :text, :options

    def initialize(type, text, options = {})
      text = text.read if text.is_a? IO
      text = self.class.interpolate(text) if options[:interpolate] # todo: test
      @type, @text, @options = type, text, options
    end

    def self.interpolate(s)
      eval("<<INTERPOLATE\n" + s + "\nINTERPOLATE").chomp
    end

    def ==(other)
      (self.type == other.type and
       self.text == other.text and
       self.options == other.options) ? true : false
    end

    def eql?(other)
      self == other
    end

    def hash
      # this is a fairly inefficient hash function but it does the trick for
      # now
      "#{type}#{text}#{options}".hash
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
erector-rails4-0.2.0 lib/erector/dependency.rb
erector-rails4-0.1.3 lib/erector/dependency.rb
erector-rails4-0.1.2 lib/erector/dependency.rb
erector-0.10.0 lib/erector/dependency.rb
erector-rails4-0.1.1 lib/erector/dependency.rb
erector-rails4-0.1.0 lib/erector/dependency.rb
erector-rails4-0.0.7 lib/erector/dependency.rb
erector-rails4-0.0.6 lib/erector/dependency.rb
erector-rails4-0.0.5 lib/erector/dependency.rb
erector-rails4-0.0.4 lib/erector/dependency.rb
erector-rails4-0.0.3 lib/erector/dependency.rb
erector-rails4-0.0.2 lib/erector/dependency.rb
erector-rails4-0.0.1 lib/erector/dependency.rb
erector-0.9.0 lib/erector/dependency.rb
erector-0.9.0.pre1 lib/erector/dependency.rb