lib/eventbrite_sdk/resource.rb in eventbrite_sdk-3.1.1 vs lib/eventbrite_sdk/resource.rb in eventbrite_sdk-3.1.2

- old
+ new

@@ -25,11 +25,11 @@ # # def publish # !new? && EventbriteSDK.post(url: path('unpublish')) # end def self.define_api_actions(*actions) - req = ->(inst, postfix) do + req = lambda do |inst, postfix| inst.instance_eval { !new? && EventbriteSDK.post(url: path(postfix)) } end actions.each do |action| if action.is_a?(Hash) @@ -49,30 +49,30 @@ def new? !id end def refresh!(request: EventbriteSDK, api_token: nil) - unless new? - reload request.get(url: path, api_token: api_token) - else + if new? false + else + reload request.get(url: path, api_token: api_token) end end def inspect "#<#{self.class}: #{JSON.pretty_generate(@attrs.to_h)}>" end def save(postfixed_path = '', api_token: nil, request: EventbriteSDK) - if changed? || !postfixed_path.empty? - response = request.post(url: path(postfixed_path), - payload: attrs.payload(self.class.prefix), - api_token: api_token) + return unless changed? || !postfixed_path.empty? - reload(response) + response = request.post(url: path(postfixed_path), + payload: attrs.payload(self.class.prefix), + api_token: api_token) - true - end + reload(response) + + true end def to_json(opts = {}) attrs.to_json(opts) end