Sha256: 999091e3e8668f095840dc37c5f4b96ed1fbf40a0230b4cef25e3b96f75921f1
Contents?: true
Size: 1.39 KB
Versions: 24
Compression:
Stored size: 1.39 KB
Contents
module MyAdmin class Application attr_accessor :key, :models def self.add(models) $applications ||= [] models = [models] unless (models.is_a? Array) models.each do |m| key = m.my_admin.application application = MyAdmin::Application.find(key) if(application) application.models << m else application = MyAdmin::Application.new application.key = key application.models = [m] $applications << application end end end def self.items $applications ||= [] $applications.uniq.compact end def self.find(key) $applications ||= [] $applications.find { |app| app.key == key } end def self.find_by_url(url) $applications ||= [] $applications.find { |app| app.url == url } end def self.remove(key) $applications.delete(MyAdmin::Application.find(key)) end def find_model_by_url(url) self.models.find { |model| model.my_admin.url == url } end def can?(user) not self.models.find { |model| model.my_admin.can?(:list, user) }.blank? end def url # I18n.t!("my_admin.urls.applications.#{self.key}") rescue self.key self.key end def title I18n.t!("activerecord.applications.my_admin.#{self.key}") rescue self.key.titleize end end end
Version data entries
24 entries across 24 versions & 1 rubygems