diff --git a/app/models/profile.rb b/app/models/profile.rb index 1586920..bd8cbfe 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -122,6 +122,14 @@ class Profile < ActiveRecord::Base self.articles.recent(self, limit) end + class << self + + def [](identifier) + self.find_by_identifier(identifier) + end + + end + def superior_instance environment end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 16b5502..18b94e0 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -201,6 +201,11 @@ class ProfileTest < Test::Unit::TestCase assert both.include?(big) end + should 'provide a shortcut for picking a profile by its identifier' do + profile = Profile.create!(:name => 'bla', :identifier => 'testprofile') + assert_equal profile, Profile['testprofile'] + end + private -- libgit2 0.21.2