Skip to content

Commit

Permalink
Changes for null attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaysingh1980 committed Jun 13, 2013
1 parent 4eb0a88 commit 809fbfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 11 additions & 9 deletions lib/sugarcrm/attributes/attribute_methods.rb
Expand Up @@ -112,16 +112,18 @@ def merge_attributes(attrs={})
def define_attribute_methods
return if attribute_methods_generated?
@attributes.keys.sort.each do |k|
# ajay Singh skip the loop if attribute is null
next if !k.present?
self.class.module_eval %Q?
def #{k}
read_attribute :#{k}
end
def #{k}=(value)
write_attribute :#{k},value
end
def #{k}\?
has_attribute\? :#{k}
end
def #{k}
read_attribute :#{k}
end
def #{k}=(value)
write_attribute :#{k},value
end
def #{k}\?
has_attribute\? :#{k}
end
?
end

Expand Down
3 changes: 2 additions & 1 deletion lib/sugarcrm/attributes/attribute_typecast.rb
Expand Up @@ -16,7 +16,8 @@ def attr_type_for(attribute)
def typecast_attributes
@attributes.each_pair do |name,value|
# skip primary key columns
next if name == "id"
# ajay Singh skip the loop if attribute is null (!name.present?)
next if (name == "id") or (!name.present?)
attr_type = attr_type_for(name)

# empty attributes should stay empty (e.g. an empty int field shouldn't be typecast as 0)
Expand Down

0 comments on commit 809fbfb

Please sign in to comment.