Class: WIS::DOM::AccountIssues
- Defined in:
- lib/dom/account_issues.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
Attributes inherited from Results
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hits, account, issues) ⇒ AccountIssues
constructor
A new instance of AccountIssues.
Constructor Details
#initialize(hits, account, issues) ⇒ AccountIssues
Returns a new instance of AccountIssues.
4 5 6 7 8 |
# File 'lib/dom/account_issues.rb', line 4 def initialize(hits, account, issues) super(hits) @account = account @issues = issues end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
2 3 4 |
# File 'lib/dom/account_issues.rb', line 2 def account @account end |
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
2 3 4 |
# File 'lib/dom/account_issues.rb', line 2 def issues @issues end |
Class Method Details
.adapt_json(data) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dom/account_issues.rb', line 10 def self.adapt_json(data) account = WIS::DOM::Account.new(data["Account"]["ID"], data["Account"]["Name"], data["Account"]["Description"]) issues = [] data["Issues"].each do |i| issue_result = WIS::DOM::IssueResult.new issue_result.issue = WIS::DOM::Issue.new(i["Issue"]["ID"], i["Issue"]["Description"]) unless i["Approved"].nil? opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Approved"]) issue_result.approved = WIS::DOM::ApprovedOpinion.new(opinion.account, opinion.issue) issue_result.approved.position = opinion.position issue_result.approved.narrative = opinion.narrative issue_result.approved.taken = opinion.taken end unless i["Unverified"].nil? opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Unverified"]) issue_result.unverified = WIS::DOM::UnverifiedOpinion.new(opinion.account, opinion.issue) issue_result.unverified.position = opinion.position issue_result.approved.narrative = opinion.narrative end unless i["Expressed"].nil? opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Expressed"]) issue_result.expressed = WIS::DOM::ExpressedOpinion.new(opinion.account, opinion.issue) issue_result.expressed.position = opinion.position issue_result.expressed.narrative = opinion.narrative issue_result.expressed.taken = opinion.taken end unless i["Unknown"].nil? opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Unknown"]) issue_result.unknown = WIS::DOM::UnknownOpinion.new(opinion.issue) issue_result.unknown.position = opinion.position end issues << issue_result end WIS::DOM::AccountIssues.new(data["Hits"], account, issues) end |
.convert_hash_to_opinion(hash) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/dom/account_issues.rb', line 53 def self.convert_hash_to_opinion(hash) account = WIS::DOM::Account.new(hash["Account"]["ID"], hash["Account"]["Name"], hash["Account"]["Description"]) unless hash["Account"].nil? issue = WIS::DOM::Issue.new(hash["Issue"]["ID"], hash["Issue"]["Description"]) opinion = WIS::DOM::Opinion.new(account, issue) opinion.narrative = hash["Narrative"] unless hash["Narrative"].nil? opinion.taken = hash["Taken"] unless hash["Taken"].nil? opinion.position = hash["Position"] unless hash["Position"].nil? opinion end |