Sha256: 8ee694f474f9ac3feb3c91d7108f3fdbc450bedaff1915f4f3504b9ef3fc03f9

Contents?: true

Size: 633 Bytes

Versions: 3

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module JsonStatham
  module Helper
    class << self
      ["included", "extended"].each do |expand|
        define_method(expand) do |base|
          base.extend HelperMethod
          base.include HelperMethod
        end
      end
    end

    module HelperMethod
      def stathamnize(name, &block)
        ensure_valid_config

        JsonStatham::Parser.call(name, &block)
      end

      private

      def ensure_valid_config
        return if JsonStatham.config.schemas_path_present?

        raise ArgumentError, "JsonStatham::Config#chemas_path can't be blank."
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_statham-0.1.3 lib/json_statham/helper.rb
json_statham-0.1.2 lib/json_statham/helper.rb
json_statham-0.1.0 lib/json_statham/helper.rb