lib/pupper/model.rb in pupper-0.1.4 vs lib/pupper/model.rb in pupper-0.1.5
- old
+ new
@@ -27,11 +27,11 @@
super(**attrs, **assocs)
changes_applied
- backend.register_model(self)
+ backend.register_model(self) unless static?
end
def primary_key
attributes.fetch(self.class.primary_key)
end
@@ -64,25 +64,14 @@
end
def backend
return if static?
@backend ||= "#{model_name.name.pluralize}Client".constantize.new
- rescue NameError
- raise NoSuchBackend, <<-ERR
- Model #{model_name.name} is looking for an API client that doesn't exist!
-
- Either a) implement the new client:
-
- # app/api_clients/#{model_name.name.sub('::', '/').downcase.pluralize}_client.rb
- class #{model_name.name.pluralize}Client < Pupper::Backend
- end
-
- Or b) use a different client instead
-
- self.backend = Other::BackendClient
-
- ERR
end
+ end
+
+ def static?
+ self.class.static?
end
def to_json(*)
attributes.except(*excluded_attrs).to_json
end