class KongSchema::Adapter

Public Class Methods

for(model) click to toggle source
# File lib/kong_schema/adapter.rb, line 5
def self.for(model)
  new(model: model)
end
new(model:) click to toggle source
# File lib/kong_schema/adapter.rb, line 9
def initialize(model:)
  @model = model
end

Public Instance Methods

changed?(current_attributes, next_attributes) click to toggle source
# File lib/kong_schema/adapter.rb, line 17
def changed?(current_attributes, next_attributes)
  next_attributes.keys.any? do |key|
    !current_attributes[key].eql?(next_attributes[key])
  end
end
create(params) click to toggle source
# File lib/kong_schema/adapter.rb, line 13
def create(params)
  @model.create(params)
end
delete(record) click to toggle source
# File lib/kong_schema/adapter.rb, line 31
def delete(record)
  record.delete
end
update(record, params) click to toggle source
# File lib/kong_schema/adapter.rb, line 23
def update(record, params)
  params.keys.each do |key|
    record.attributes[key] = params[key]
  end

  record.save
end