Sha256: a20da54940008b30cfbfb4342bf476469cd0335608d0efc2a73153bec16727f2

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

require_relative 'record/kit'
require_relative 'record/family'
require_relative 'record/library'
require_relative 'record/variation'

module Typekit
  module Record
    def self.identify(name)
      if Element.dictionary.key?(Helper.tokenize(name, pluralize: false))
        :collection
      elsif Element.dictionary.key?(Helper.tokenize(name))
        :element
      end
    end

    def self.build(name, client)
      klass = Element.classify(name)
      Class.new(klass) do
        extend Client::Proxy

        connect(client, Helper.tokenize(name))

        singleton_class.instance_eval do
          define_method(:new) do |*arguments|
            klass.new(client, *arguments)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typekit-client-0.0.6 lib/typekit/record.rb