Sha256: 3d8e0eb9eaeb50164624582dacedbfeb438c55f582565b0274669461133a7917

Contents?: true

Size: 582 Bytes

Versions: 9

Compression:

Stored size: 582 Bytes

Contents

require "yaml"

module Middleman::Features::Data
  class << self
    def registered(app)
      app.helpers Middleman::Features::Data::Helpers
    end
    alias :included :registered
  end
  
  module Helpers
    def data
      @@data ||= Middleman::Features::Data::DataObject.new(self)
    end
  end
  
  class DataObject
    def initialize(app)
      @app = app
    end
    
    def method_missing(path)
      file_path = File.join(@app.class.root, "data", "#{path}.yml")      
      if File.exists? file_path
        return YAML.load_file(file_path)
      end
    end
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
middleman-1.2.1 lib/middleman/features/data.rb
middleman-1.2.0 lib/middleman/features/data.rb
middleman-1.1.6 lib/middleman/features/data.rb
middleman-1.1.5 lib/middleman/features/data.rb
middleman-1.1.4 lib/middleman/features/data.rb
middleman-1.1.3 lib/middleman/features/data.rb
middleman-1.1.2 lib/middleman/features/data.rb
middleman-1.1.1.a lib/middleman/features/data.rb
middleman-1.1.0.1 lib/middleman/features/data.rb