Module: DotloopApi::EndPoints::ModelBuilder
- Included in:
- Base
- Defined in:
- lib/dotloop_api/end_points/model_builder.rb
Instance Method Summary collapse
Instance Method Details
#build_details(attrs) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/dotloop_api/end_points/model_builder.rb', line 24 def build_details(attrs) data = fix_hash(attrs) data.keys.each_with_object({}) do |key, memo| memo[key] = detail_model(key).new(data[key]) end end |
#build_documents(attrs) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dotloop_api/end_points/model_builder.rb', line 13 def build_documents(attrs) attrs['documents'].map do |doc_attrs| doc = DotloopApi::Models::Profile::Loop::Folder::Document.new(doc_attrs) doc.client = @client doc.profile_id = @profile_id doc.loop_id = @loop_id doc.folder_id = attrs['id'] doc end end |
#build_model(attrs) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/dotloop_api/end_points/model_builder.rb', line 4 def build_model(attrs) model = @type.new(fix_nested_attributes(attrs)) model.client = @client if model.respond_to?(:client) model.profile_id = @profile_id if model.respond_to?(:profile_id) model.loop_id = @loop_id if model.respond_to?(:loop_id) model.folder_id = @folder_id if model.respond_to?(:folder_id) model end |