Module: Typekit::Record
- Defined in:
- lib/typekit/record.rb,
lib/typekit/record/kit.rb,
lib/typekit/record/base.rb,
lib/typekit/record/family.rb,
lib/typekit/record/library.rb,
lib/typekit/record/variation.rb
Defined Under Namespace
Classes: Base, Family, Kit, Library, Variation
Class Method Summary
collapse
Class Method Details
.build(name, *arguments) ⇒ Object
31
32
33
|
# File 'lib/typekit/record.rb', line 31
def self.build(name, *arguments)
classify(name).new(*arguments)
end
|
.classify(name) ⇒ Object
19
20
21
|
# File 'lib/typekit/record.rb', line 19
def self.classify(name)
mapping[Helper.singularize(name.to_s).to_sym]
end
|
.identify(name) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/typekit/record.rb', line 23
def self.identify(name)
if mapping.include?(name.to_s.to_sym)
:record
elsif mapping.include?(Helper.singularize(name.to_s).to_sym)
:collection
end
end
|
.mapping ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/typekit/record.rb', line 9
def self.mapping
@mapping ||= Hash[
ObjectSpace.each_object(Class).select do |klass|
klass < Base && klass.name
end.map do |klass|
[ klass.name.downcase.sub(/^.*::/, '').to_sym, klass ]
end
]
end
|