class Billogram::RelationBuilder
Attributes
attributes[R]
resource[R]
Public Class Methods
new(resource, attributes)
click to toggle source
# File lib/billogram/relation_builder.rb, line 7 def initialize(resource, attributes) @resource = resource @attributes = attributes end
Public Instance Methods
call()
click to toggle source
# File lib/billogram/relation_builder.rb, line 12 def call resource_relations.each do |relation| build_relation(relation) end end
Private Instance Methods
build_relation(relation)
click to toggle source
# File lib/billogram/relation_builder.rb, line 24 def build_relation(relation) attrs = attributes.delete(relation.name) return unless attrs value = relation.relation_class.build_objects(attrs) resource.public_send("#{relation.name}=", value) end
resource_relations()
click to toggle source
# File lib/billogram/relation_builder.rb, line 20 def resource_relations resource.class.relations end