Module: Typekit::Element::Serialization

Included in:
Record::Family, Record::Kit, Record::Variation
Defined in:
lib/typekit/element/serialization.rb

Instance Method Summary collapse

Instance Method Details

#serialize(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/typekit/element/serialization.rb', line 4

def serialize(options = {})
  keys = attributes.keys
  keys = keys & Array(options[:only]) if options.key?(:only)
  Hash[
    keys.map do |key|
      value = attributes[key]
      value = value.serialize if value.respond_to?(:serialize)
      [key, value]
    end
  ]
end