metamaps--metamaps/app/models/permitted_params.rb

38 lines
776 B
Ruby
Raw Normal View History

2016-09-24 03:00:46 +00:00
# frozen_string_literal: true
2017-11-25 19:23:47 +00:00
2018-01-21 22:21:00 +00:00
class PermittedParams
%w[map synapse topic mapping token].each do |kind|
define_method(kind) do
permitted_attributes = send("#{kind}_attributes")
2018-01-21 22:21:00 +00:00
@params.require(kind).permit(*permitted_attributes)
end
alias_method :"api_#{kind}", kind.to_sym
end
2018-01-21 22:21:00 +00:00
def initialize(params)
@params = params
end
alias read_attribute_for_serialization send
def token_attributes
[:description]
end
def map_attributes
%i[name desc permission arranged]
end
def synapse_attributes
%i[desc category weight permission topic1_id topic2_id]
end
def topic_attributes
%i[name desc link permission metacode_id]
end
def mapping_attributes
%i[xloc yloc map_id mappable_type mappable_id]
end
end