sugarcrm 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
@@ -56,12 +56,13 @@ module SugarCRM
|
|
56
56
|
@original - @collection
|
57
57
|
end
|
58
58
|
|
59
|
-
# Removes
|
59
|
+
# Removes a record from the collection, uses the id of the record as a test for inclusion.
|
60
60
|
def delete(record)
|
61
61
|
load
|
62
62
|
raise InvalidRecord, "#{record.class} does not have a valid :id!" if record.id.empty?
|
63
63
|
@collection.delete record
|
64
64
|
end
|
65
|
+
alias :remove :delete
|
65
66
|
|
66
67
|
# Checks if a record is included in the current collection. Uses id's as comparison
|
67
68
|
def include?(record)
|
@@ -9,6 +9,14 @@ module SugarCRM; module AttributeMethods
|
|
9
9
|
end
|
10
10
|
fields
|
11
11
|
end
|
12
|
+
# Returns the table name for a given attribute
|
13
|
+
def table_name_for(attribute)
|
14
|
+
table_name = self._module.table_name
|
15
|
+
if attribute.to_s =~ /_c$/
|
16
|
+
table_name = self._module.custom_table_name
|
17
|
+
end
|
18
|
+
table_name
|
19
|
+
end
|
12
20
|
end
|
13
21
|
|
14
22
|
# Determines if attributes or associations have been changed
|
data/lib/sugarcrm/base.rb
CHANGED
@@ -167,12 +167,7 @@ module SugarCRM; class Base
|
|
167
167
|
|
168
168
|
value = $2 # strip the operator from value passed to query
|
169
169
|
value = value.strip[/'?([^']*)'?/,1]
|
170
|
-
|
171
|
-
condition_attribute = "#{self._module.table_name}.#{column}"
|
172
|
-
else
|
173
|
-
condition_attribute = column # if setting a condition on a custom attribute (i.e. created by user in Studio), don't add model table name (or query breaks)
|
174
|
-
end
|
175
|
-
conditions << "#{condition_attribute} #{operator} \'#{value}\'"
|
170
|
+
conditions << "#{table_name_for(column)}.#{column} #{operator} \'#{value}\'"
|
176
171
|
}
|
177
172
|
end
|
178
173
|
conditions.join(" AND ")
|
@@ -121,8 +121,12 @@ module SugarCRM; class Connection
|
|
121
121
|
raise SugarCRM::EmptyResponse unless @response.body
|
122
122
|
# Some methods are dumb and don't return a JSON Response
|
123
123
|
return @response.body if RESPONSE_IS_NOT_JSON.include? @request.method
|
124
|
-
|
125
|
-
|
124
|
+
begin
|
125
|
+
# Push it through the old meat grinder.
|
126
|
+
response_json = ActiveSupport::JSON.decode(@response.body)
|
127
|
+
rescue StandardError => e
|
128
|
+
raise UnhandledResponse, @response.body
|
129
|
+
end
|
126
130
|
# Empty result. Is this wise?
|
127
131
|
return false if response_json["result_count"] == 0
|
128
132
|
# Filter debugging on REALLY BIG responses
|
data/lib/sugarcrm/module.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module SugarCRM
|
2
2
|
# A class for handling SugarCRM Modules
|
3
3
|
class Module
|
4
|
-
attr :name,
|
5
|
-
attr :table_name,
|
6
|
-
attr :
|
7
|
-
attr :
|
8
|
-
attr :
|
4
|
+
attr :name, true
|
5
|
+
attr :table_name, true
|
6
|
+
attr :custom_table_name, true
|
7
|
+
attr :klass, true
|
8
|
+
attr :fields, true
|
9
|
+
attr :link_fields, true
|
9
10
|
|
10
11
|
# Dynamically register objects based on Module name
|
11
12
|
# I.e. a SugarCRM Module named Users will generate
|
@@ -14,6 +15,7 @@ module SugarCRM
|
|
14
15
|
@name = name
|
15
16
|
@klass = name.classify
|
16
17
|
@table_name = name.tableize
|
18
|
+
@custom_table_name = @table_name + "_cstm"
|
17
19
|
@fields = {}
|
18
20
|
@link_fields = {}
|
19
21
|
@fields_registered = false
|
data/test/test_module.rb
CHANGED
@@ -14,5 +14,9 @@ class TestModule < Test::Unit::TestCase
|
|
14
14
|
should "return required fields when #required_fields" do
|
15
15
|
assert SugarCRM::User._module.required_fields.include? :user_name
|
16
16
|
end
|
17
|
+
|
18
|
+
should "return the custom table name when #custom_table_name" do
|
19
|
+
assert_equal "accounts_cstm", SugarCRM::Account._module.custom_table_name
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 3
|
9
|
+
version: 0.9.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Carl Hicks
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-05 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -193,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
193
|
requirements:
|
194
194
|
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
hash:
|
196
|
+
hash: -1102479478873110582
|
197
197
|
segments:
|
198
198
|
- 0
|
199
199
|
version: "0"
|