lib/eco/api/common/people/person_factory.rb in eco-helpers-0.6.17 vs lib/eco/api/common/people/person_factory.rb in eco-helpers-0.7.1
- old
+ new
@@ -2,12 +2,10 @@
module API
module Common
module People
class PersonFactory
- include Common::People
-
attr_reader :schema_attrs
def initialize(person: {}, schema: {}, account: {}, modifier: Common::People::PersonModifier.new)
@modifier = Common::People::PersonModifier.new(modifier)
@person = person
@@ -41,13 +39,13 @@
private
def klass
if @modifier.external?
- EXTERNAL::Person
+ Ecoportal::API::V1::Person
else
- INTERNAL::Person
+ Ecoportal::API::Internal::Person
end
end
def new_hash(modifier)
modifier = Common::People::PersonModifier.new(modifier)
@@ -67,27 +65,27 @@
doc_acc = account_hash(account)
doc.merge({ "account" => doc_acc })
end
def person_hash(person)
- case
- when is_person?(person)
+ case person
+ when Ecoportal::API::V1::Person
JSON.parse(person.doc.to_json)
- when person.is_a?(Hash)
+ when Hash
JSON.parse(person.to_json)
else
{}
end
end
def details_hash(details)
- case
- when details.is_a?(EXTERNAL::PersonDetails)
+ case details
+ when Ecoportal::API::V1::PersonDetails
doc = JSON.parse(details.doc.to_json)
- when details.is_a?(EXTERNAL::PersonSchema)
+ when Ecoportal::API::V1::PersonSchema
doc =JSON.parse(details.doc.to_json)
- when details.is_a?(Hash)
+ when Hash
doc = JSON.parse(details.to_json)
doc = doc["details"] if doc.key?("details")
else
doc = {}
end
@@ -95,10 +93,10 @@
doc
end
def account_hash(account)
case
- when account.is_a?(INTERNAL::Account)
+ when account.is_a?(Ecoportal::API::Internal::Account)
JSON.parse(account.doc.to_json)
when account.is_a?(Hash)
doc = JSON.parse(account.to_json)
doc["account"] if doc.key?("account")
else