Class: Ohbjects::QuoteBuilder

Inherits:
Object
  • Object
show all
Extended by:
Buildable
Defined in:
lib/ohbjects/quote.rb

Instance Attribute Summary

Attributes included from Buildable

#spec

Class Method Summary collapse

Methods included from Buildable

build?, builds, extended, underscore

Class Method Details

.build(fragment) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ohbjects/quote.rb', line 8

def build(fragment)
  quote = Quote.new

  fragment.attributes.each do |key, attr|
    method = "#{underscore(key)}="

    next unless quote.respond_to?(method)

    quote.send(method, attr.value)
  end

  quote.description = 
    fragment.attributes["shortDescription"].value

  quote
end