Sha256: aa68be7b11a620a077fdb59ae185bf3f38ceb3e5b746d9d5fb016693cc922265

Contents?: true

Size: 430 Bytes

Versions: 58

Compression:

Stored size: 430 Bytes

Contents

# encoding: utf-8

module FromFile

  module ClassMethods
    def from_file(path)
      new.tap do |obj|
        obj.from_file(path)
      end
    end
  end

  def from_file(path)
    if File.exists?(path) && File.readable?(path)
      self.instance_eval(IO.read(path), path, 1)
    else
      raise IOError, "Cannot open or read #{path}!"
    end
  end

  def self.included(receiver)
    receiver.extend(ClassMethods)
  end

end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
liquid-ext-3.5.3 lib/liquid/from_file.rb
liquid-ext-3.5.2 lib/liquid/from_file.rb
liquid-ext-3.5.0 lib/liquid/from_file.rb
liquid-ext-3.4.2 lib/liquid/from_file.rb
liquid-ext-3.4.1 lib/liquid/from_file.rb
liquid-ext-3.4.0 lib/liquid/from_file.rb
liquid-ext-3.3.10 lib/liquid/from_file.rb
liquid-ext-3.3.9 lib/liquid/from_file.rb
liquid-ext-3.3.8 lib/liquid/from_file.rb
liquid-ext-3.3.7 lib/liquid/from_file.rb
liquid-ext-3.3.6 lib/liquid/from_file.rb
liquid-ext-3.3.5 lib/liquid/from_file.rb
liquid-ext-3.3.4 lib/liquid/from_file.rb
liquid-ext-3.3.3 lib/liquid/from_file.rb
liquid-ext-3.3.2 lib/liquid/from_file.rb
liquid-ext-3.3.0 lib/liquid/from_file.rb
liquid-ext-3.2.0 lib/liquid/from_file.rb
liquid-ext-3.1.2 lib/liquid/from_file.rb
liquid-ext-3.1.1 lib/liquid/from_file.rb
liquid-ext-3.1.0 lib/liquid/from_file.rb