Sha256: 0157a0596bc16fe3ef398ab349b72ba76fab3ca3b00435559d5bf7b3e2a55025

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

require 'conifer/version'
require 'conifer/file'

require 'active_support/concern'

module Conifer
  extend ActiveSupport::Concern

  class_methods do
    def conifer(file, prefix: nil, dir: nil, method: 'conifer', singleton: false)
      body = proc do
        return instance_variable_get("@conifer_#{method}") if instance_variable_defined?("@conifer_#{method}")

        directory = dir || ::File.expand_path(::File.dirname(caller_locations.first.path))
        instance_variable_set "@conifer_#{method}", Conifer::File.new(file, prefix: prefix, dir: directory)
      end

      if singleton
        define_singleton_method method, &body
      else
        define_method method, &body
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conifer-0.2.0 lib/conifer.rb