Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeen committed Feb 28, 2024
1 parent 8ed3405 commit 2882008
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
8 changes: 4 additions & 4 deletions lib/graphiti/resource/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def assign(assign_params, meta = nil, action_name = nil)

run_callbacks :attributes, action_name, assign_params, meta do |params|
model_instance = if action_name != :create && id
self.class._find(id: id).data
else
call_with_meta(:build, model, meta)
end
self.class._find(id: id).data
else
call_with_meta(:build, model, meta)
end
call_with_meta(:assign_attributes, model_instance, params, meta)
model_instance
end
Expand Down
4 changes: 2 additions & 2 deletions lib/graphiti/resource_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def data
end
end

alias to_a data
alias resolve_data data
alias_method :to_a, :data
alias_method :resolve_data, :data

def meta
@meta ||= data.respond_to?(:meta) ? data.meta : {}
Expand Down
2 changes: 1 addition & 1 deletion lib/graphiti/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def strip_relationships!(hash)
end

def strip_relationships?
return false unless Graphiti.config.links_on_demand
return false unless Graphiti.config.links_on_demand

params = Graphiti.context[:object].try(:params) || {}
[false, nil, "false"].include?(params[:links])
Expand Down
18 changes: 8 additions & 10 deletions spec/integration/rails/callbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ApplicationResource < Graphiti::Resource

class EmployeeResource < ApplicationResource
self.model = Employee
self.type= "employees"
self.type = "employees"

before_attributes :one
before_attributes :two
Expand Down Expand Up @@ -208,7 +208,7 @@ def params
{
data: {
type: "employees",
attributes: { first_name: "Jane"}
attributes: {first_name: "Jane"}
}
}
end
Expand Down Expand Up @@ -244,16 +244,14 @@ def params
describe "update callbacks" do
let!(:employee) { Employee.create!(first_name: "asdf") }
let(:payload) {
{ id: employee.id,
data: {
id: employee.id,
type: 'employees',
attributes: { first_name: "Jane" }
}
}
{id: employee.id,
data: {
id: employee.id,
type: "employees",
attributes: {first_name: "Jane"}
}}
}


it "fires hooks in order" do
expect {
put :update, params: payload
Expand Down
2 changes: 1 addition & 1 deletion spec/support/rails/employee_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create

def update
employee = resource.find(params)

if employee.update_attributes
render jsonapi: employee
else
Expand Down

0 comments on commit 2882008

Please sign in to comment.