Module: Typekit::Record

Defined in:
lib/typekit/record.rb,
lib/typekit/record/kit.rb,
lib/typekit/record/family.rb,
lib/typekit/record/library.rb,
lib/typekit/record/variation.rb

Defined Under Namespace

Classes: Family, Kit, Library, Variation

Class Method Summary collapse

Class Method Details

.build(name, client) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/typekit/record.rb', line 16

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

.identify(name) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/typekit/record.rb', line 8

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