2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2016-03-11 06:16:04 +00:00
|
|
|
class PermittedParams < Struct.new(:params)
|
2016-07-26 00:14:23 +00:00
|
|
|
%w(map synapse topic mapping token).each do |kind|
|
2016-03-11 06:16:04 +00:00
|
|
|
define_method(kind) do
|
2016-07-26 00:14:23 +00:00
|
|
|
permitted_attributes = send("#{kind}_attributes")
|
2016-03-11 06:16:04 +00:00
|
|
|
params.require(kind).permit(*permitted_attributes)
|
|
|
|
end
|
|
|
|
alias_method :"api_#{kind}", kind.to_sym
|
|
|
|
end
|
|
|
|
|
2016-07-26 00:14:23 +00:00
|
|
|
alias read_attribute_for_serialization send
|
2016-03-11 06:16:04 +00:00
|
|
|
|
|
|
|
def token_attributes
|
|
|
|
[:description]
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
|
2016-03-11 06:16:04 +00:00
|
|
|
def map_attributes
|
|
|
|
[:name, :desc, :permission, :arranged]
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
|
2016-03-11 06:16:04 +00:00
|
|
|
def synapse_attributes
|
2016-09-28 02:32:28 +00:00
|
|
|
[:desc, :category, :weight, :permission, :topic1_id, :topic2_id]
|
2016-03-11 06:16:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def topic_attributes
|
|
|
|
[:name, :desc, :link, :permission, :metacode_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def mapping_attributes
|
|
|
|
[:xloc, :yloc, :map_id, :mappable_type, :mappable_id]
|
|
|
|
end
|
|
|
|
end
|