class Parse::Pointer
Attributes
object[R]
parse_object_id[R]
Public Class Methods
new(hash, parent=nil)
click to toggle source
# File lib/parse/pointer.rb, line 6 def initialize hash, parent=nil @raw_hash = hash @parse_object_id = hash['objectId'] @parent_object = parent if @raw_hash.has_key? 'body' @object = pointed_parse_class.new @raw_hash['body'] end end
Public Instance Methods
load()
click to toggle source
# File lib/parse/pointer.rb, line 16 def load @object ||= pointed_parse_class.find_by_id @raw_hash['objectId'] end
load!()
click to toggle source
TODO: should be refactored
# File lib/parse/pointer.rb, line 21 def load! @object ||= pointed_parse_class.find_by_id! @raw_hash['objectId'] end
to_h()
click to toggle source
# File lib/parse/pointer.rb, line 25 def to_h { "__type" => "Pointer", "className" => "#{@raw_hash['className']}", "objectId" => "#{@raw_hash['objectId']}" } end
to_json(*args)
click to toggle source
# File lib/parse/pointer.rb, line 33 def to_json *args to_h.to_json end
Private Instance Methods
pointed_parse_class()
click to toggle source
# File lib/parse/pointer.rb, line 39 def pointed_parse_class included_parse_class_name = @raw_hash['className'] mod = @parent_object.class.name.include?('::') ? \ eval(@perent_object.class.name.split('::')[0..-2]) : ::Object Parse::Object included_parse_class_name, mod end