Skip to content

Commit

Permalink
Merge pull request #146 from lenart/fix_callbacks_on_model_save
Browse files Browse the repository at this point in the history
Fix callbacks on model save
  • Loading branch information
adelevie committed Dec 30, 2015
2 parents 82ad4fa + 63b627e commit bb55b21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ gem "rest-client"
gem "activesupport"
gem "activemodel"
gem "json"
gem "test-unit"
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ GEM
bundler (~> 1.0)
git (>= 1.2.5)
rake
json (1.7.7)
json (1.8.2)
mime-types (1.22)
multi_json (1.7.2)
power_assert (0.2.2)
rake (10.0.4)
reek (1.2.13)
ripper_ruby_parser (~> 0.0.7)
Expand All @@ -36,6 +37,8 @@ GEM
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
sexp_processor (3.2.0)
test-unit (3.0.9)
power_assert
turn (0.9.6)
ansi
vcr (2.4.0)
Expand All @@ -53,6 +56,7 @@ DEPENDENCIES
json
reek (~> 1.2.8)
rest-client
test-unit
turn
vcr
webmock
10 changes: 5 additions & 5 deletions lib/parse_resource/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def self.load_settings
@@settings ||= begin
path = "config/parse_resource.yml"
environment = defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : ENV["RACK_ENV"]
if FileTest.exist? (path)
if FileTest.exist? (path)
YAML.load(ERB.new(File.new(path).read).result)[environment]
elsif ENV["PARSE_RESOURCE_APPLICATION_ID"] && ENV["PARSE_RESOURCE_MASTER_KEY"]
settings = HashWithIndifferentAccess.new
Expand Down Expand Up @@ -426,9 +426,9 @@ def save
if valid?
run_callbacks :save do
if new?
return create
create
else
return update
update
end
end
else
Expand Down Expand Up @@ -463,11 +463,11 @@ def update(attributes = {})
def merge_attributes(results)
@attributes.merge!(results)
@attributes.merge!(@unsaved_attributes)

merge_relations
@unsaved_attributes = {}


create_setters_and_getters!
@attributes
end
Expand Down

0 comments on commit bb55b21

Please sign in to comment.