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
|
|
|
|
[:desc, :category, :weight, :permission, :node1_id, :node2_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def topic_attributes
|
|
|
|
[:name, :desc, :link, :permission, :metacode_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def mapping_attributes
|
|
|
|
[:xloc, :yloc, :map_id, :mappable_type, :mappable_id]
|
|
|
|
end
|
|
|
|
end
|