class <%= config[:class_name] %> attr_reader :user, :<%= config[:resource] %> def initialize(user, <%= config[:resource] %>) @user = user @<%= config[:resource] %> = <%= config[:resource] %> end if ActiveRecord::Base.connection.table_exists?(:<%= config[:resource] %>_roles) <%= config[:constant] %>Role.pluck(:permission).each do |permission| define_method("#{permission}?") do <%= config[:constant] %>Role.find_by(permission: permission).send(user.role.<%= config[:resource] %>) end end end end