Class: Bizside::Redmine::ResultSet
- Inherits:
-
Object
- Object
- Bizside::Redmine::ResultSet
- Includes:
- Enumerable
- Defined in:
- lib/bizside/redmine/result_set.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #==(target) ⇒ Object
- #each ⇒ Object
-
#initialize(key, status, json_string = nil) ⇒ ResultSet
constructor
A new instance of ResultSet.
Constructor Details
#initialize(key, status, json_string = nil) ⇒ ResultSet
Returns a new instance of ResultSet.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bizside/redmine/result_set.rb', line 9 def initialize(key, status, json_string = nil) @key = key @status = status if json_string.present? json = ActiveSupport::JSON.decode(json_string.force_encoding('UTF-8')) @rows = key.present? ? json[key.to_s] : json @errors = json['errors'] else warn(status) end @rows ||= [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/bizside/redmine/result_set.rb', line 7 def errors @errors end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/bizside/redmine/result_set.rb', line 4 def key @key end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
6 7 8 |
# File 'lib/bizside/redmine/result_set.rb', line 6 def rows @rows end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/bizside/redmine/result_set.rb', line 5 def status @status end |
Instance Method Details
#==(target) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/bizside/redmine/result_set.rb', line 24 def ==(target) self.key == target.key && self.status == target.status && self.rows == target.rows && self.errors == target.errors end |
#each ⇒ Object
31 32 33 34 35 |
# File 'lib/bizside/redmine/result_set.rb', line 31 def each rows.each do |hash| yield hash end end |