Parsistence 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,9 @@ module Parsistence
27
27
  method = method.to_sym
28
28
  if fields.include?(method)
29
29
  return getField(method)
30
+ elsif fields.map { |f| "#{f}=".include?(method)}
31
+ method = method.split("=")[0]
32
+ return setField(method, args.first)
30
33
  elsif relations.include?(method)
31
34
  return getRelation(method)
32
35
  elsif relations.map {|r| "#{r}=".include?(method)}
@@ -65,14 +68,14 @@ module Parsistence
65
68
  raise "Parsistence Exception: Invalid relation name #{field} for object #{self.class.to_s}"
66
69
  end
67
70
 
68
- def setRelation(relation, value)
71
+ def setRelation(field, value)
69
72
  value = value.PFObject if value.respond_to? :PFObject # unwrap object
70
- # return setRelation(relation, value) # This SHOULD work
73
+ # return setRelation(field, value) # This SHOULD work
71
74
 
72
- relation = @PFObject.relationforKey(relation)
75
+ relation = @PFObject.relationforKey(field)
73
76
 
74
- return relation.addObject(value) if relations.include? relation.to_sym
75
- raise "Parsistence Exception: Invalid relation name #{relation} for object #{self.class.to_s}" unless relations.include? relation.to_sym
77
+ return relation.addObject(value) if relations.include? field.to_sym
78
+ raise "Parsistence Exception: Invalid relation name #{field} for object #{self.class.to_s}" unless relations.include? relation.to_sym
76
79
  end
77
80
 
78
81
  def attributes
@@ -85,8 +88,11 @@ module Parsistence
85
88
 
86
89
  def attributes=(hashValue)
87
90
  hashValue.each do |k, v|
88
- next if v.nil? # Protection
89
- setField(k, v) unless k.nil?
91
+ if self.respond_to? "#{k}="
92
+ self.send("#{k}=", v)
93
+ else
94
+ setField(k, v) unless k.nil?
95
+ end
90
96
  end
91
97
  end
92
98
 
@@ -1,3 +1,3 @@
1
1
  module Parsistence
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Parsistence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: