Module: Harvest::Model::InstanceMethods
- Defined in:
- lib/harvest/model.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_json(args = {}) ⇒ Object
- #impersonated_user_id ⇒ Object
- #json_root ⇒ Object
- #to_json(*args) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/harvest/model.rb', line 23 def ==(other) other.kind_of?(self.class) && id == other.id end |
#as_json(args = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/harvest/model.rb', line 13 def as_json(args = {}) inner_json = self.to_hash.stringify_keys inner_json.delete('cache_version') if self.class.skip_json_root? inner_json else { self.class.json_root => inner_json } end end |
#impersonated_user_id ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/harvest/model.rb', line 27 def impersonated_user_id if respond_to?(:of_user) && respond_to?(:user_id) of_user || user_id elsif !respond_to?(:of_user) && respond_to?(:user_id) user_id elsif respond_to?(:of_user) of_user end end |
#json_root ⇒ Object
37 38 39 |
# File 'lib/harvest/model.rb', line 37 def json_root self.class.json_root end |
#to_json(*args) ⇒ Object
9 10 11 |
# File 'lib/harvest/model.rb', line 9 def to_json(*args) as_json(*args).to_json(*args) end |