databasedotcom 1.0.8 → 1.0.9

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.
@@ -77,7 +77,8 @@ module Databasedotcom
77
77
  # c.save
78
78
  def save
79
79
  attr_hash = {}
80
- self.class.description["fields"].select { |f| f["updateable"] }.collect { |f| f["name"] }.each { |attr| attr_hash[attr] = self.send(attr) }
80
+ selection_attr = self.Id.nil? ? "createable" : "updateable"
81
+ self.class.description["fields"].select { |f| f[selection_attr] }.collect { |f| f["name"] }.each { |attr| attr_hash[attr] = self.send(attr) }
81
82
 
82
83
  if self.Id.nil?
83
84
  self.client.create(self.class, attr_hash)
@@ -135,7 +136,13 @@ module Databasedotcom
135
136
  self.description["fields"].each do |field|
136
137
  name = field["name"]
137
138
  attr_accessor name.to_sym
138
- self.type_map[name] = {:type => field["type"], :label => field["label"], :picklist_values => field["picklistValues"], :updateable? => field["updateable"]}
139
+ self.type_map[name] = {
140
+ :type => field["type"],
141
+ :label => field["label"],
142
+ :picklist_values => field["picklistValues"],
143
+ :updateable? => field["updateable"],
144
+ :createable? => field["createable"]
145
+ }
139
146
  end
140
147
  end
141
148
 
@@ -162,6 +169,11 @@ module Databasedotcom
162
169
  self.type_map_attr(attr_name, :updateable?)
163
170
  end
164
171
 
172
+ # Returns true if the attribute +attr_name+ can be created. Raises ArgumentError if attribute does not exist.
173
+ def self.createable?(attr_name)
174
+ self.type_map_attr(attr_name, :createable?)
175
+ end
176
+
165
177
  # Delegates to Client.find with arguments +record_id+ and self
166
178
  #
167
179
  # client.materialize("Car")
@@ -1,3 +1,3 @@
1
1
  module Databasedotcom
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: databasedotcom
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.8
5
+ version: 1.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Glenn Gillen, Danny Burkes & Richard Zhao
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-07 00:00:00 Z
13
+ date: 2011-09-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multipart-post