Dir[File.dirname(__FILE__) + '/lib/easy_project_attachments/easy_extensions/helpers/*.rb'].each {|file| require_dependency file }
Dir[File.dirname(__FILE__) + '/lib/easy_project_attachments/redmine/controllers/*.rb'].each {|file| require_dependency file }
Dir[File.dirname(__FILE__) + '/lib/easy_project_attachments/redmine/helpers/*.rb'].each {|file| require_dependency file }
Dir[File.dirname(__FILE__) + '/lib/easy_project_attachments/redmine/models/*.rb'].each {|file| require_dependency file }
Dir[File.dirname(__FILE__) + '/lib/easy_project_attachments/redmine/others/*.rb'].each {|file| require_dependency file }

ActiveSupport.on_load(:easyproject, yield: true) do
  Redmine::AccessControl.map do |map|
    map.easy_category :documents do |pmap|
      pmap.permission :view_easy_project_attachments, { :easy_project_attachments => :index }, :read => true
    end
  end
end

ActionDispatch::Reloader.to_prepare do

  require 'easy_project_attachments/hooks'

  EasyQuery.map do |query|
    query.register EasyProjectAttachmentQuery
  end

end
