Class: Wuclan::JsonModel::GenericJsonParser
- Inherits:
-
Object
- Object
- Wuclan::JsonModel::GenericJsonParser
- Defined in:
- lib/wuclan/twitter/parse/generic_json_parser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
Class Method Summary collapse
-
.new_from_json(json_str, *args) ⇒ Object
Safely parse the json object and instantiate with the raw hash.
Instance Method Summary collapse
- #healthy? ⇒ Boolean
-
#initialize(raw) ⇒ GenericJsonParser
constructor
A new instance of GenericJsonParser.
Constructor Details
#initialize(raw) ⇒ GenericJsonParser
Returns a new instance of GenericJsonParser.
5 6 7 |
# File 'lib/wuclan/twitter/parse/generic_json_parser.rb', line 5 def initialize raw self.raw = raw end |
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/wuclan/twitter/parse/generic_json_parser.rb', line 4 def raw @raw end |
Class Method Details
.new_from_json(json_str, *args) ⇒ Object
Safely parse the json object and instantiate with the raw hash
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wuclan/twitter/parse/generic_json_parser.rb', line 13 def self.new_from_json json_str, *args return unless json_str begin raw = JSON.load(json_str) or return rescue Exception => e; warn e return end self.new raw, *args end |
Instance Method Details
#healthy? ⇒ Boolean
8 |
# File 'lib/wuclan/twitter/parse/generic_json_parser.rb', line 8 def healthy?() raw && raw.is_a?(Hash) end |