Module: ParseModel::Model
- Defined in:
- lib/ParseModel/Model.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/ParseModel/Model.rb', line 14
def method_missing(method, *args, &block)
if fields.include?(method)
@PFObject.objectForKey(method)
elsif fields.map {|f| "#{f}="}.include?("#{method}")
method = method.split("=")[0]
@PFObject.setObject(args.first, forKey:method)
elsif @PFObject.respond_to?(method)
@PFObject.send(method, *args, &block)
else
super
end
end
|
Instance Attribute Details
#PFObject ⇒ Object
Returns the value of attribute PFObject.
4
5
6
|
# File 'lib/ParseModel/Model.rb', line 4
def PFObject
@PFObject
end
|
Class Method Details
.included(base) ⇒ Object
50
51
52
|
# File 'lib/ParseModel/Model.rb', line 50
def self.included(base)
base.extend(ClassMethods)
end
|
Instance Method Details
#fields ⇒ Object
27
28
29
|
# File 'lib/ParseModel/Model.rb', line 27
def fields
self.class.send(:get_fields)
end
|
#initialize(pf_object = nil) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/ParseModel/Model.rb', line 6
def initialize(pf_object=nil)
if pf_object
@PFObject = pf_object
else
@PFObject = PFObject.objectWithClassName(self.class.to_s)
end
end
|