SHIMADA Koji
null+****@clear*****
Thu Sep 20 10:31:29 JST 2012
SHIMADA Koji 2012-09-20 10:31:29 +0900 (Thu, 20 Sep 2012) New Revision: a76960994fdd02c0dc15ea59daff71508ee01ab3 https://github.com/logaling/logaling-server/commit/a76960994fdd02c0dc15ea59daff71508ee01ab3 Merged c5d082c: Merge pull request #13 from logaling/enable-creating-user-glossary Log: Extract #find_glossary for now Modified files: app/models/user_glossary.rb Modified: app/models/user_glossary.rb (+8 -4) =================================================================== --- app/models/user_glossary.rb 2012-09-20 10:15:45 +0900 (431b5a1) +++ app/models/user_glossary.rb 2012-09-20 10:31:29 +0900 (a55359c) @@ -16,7 +16,7 @@ class UserGlossary < ActiveRecord::Base def add!(term) raise Logaling::TermError unless term.valid? - glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language) + glossary = find_glossary raise Logaling::GlossaryNotFound unless glossary if glossary.bilingual_pair_exists?(term.source_term, term.target_term) @@ -30,7 +30,7 @@ class UserGlossary < ActiveRecord::Base def update(term, new_term) raise Logaling::TermError unless term.valid? - glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language) + glossary = find_glossary raise Logaling::GlossaryNotFound unless glossary unless glossary.bilingual_pair_exists?(term.source_term, term.target_term) @@ -44,7 +44,7 @@ class UserGlossary < ActiveRecord::Base def delete(term) raise Logaling::TermError unless term.valid? - glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language) + glossary = find_glossary raise Logaling::GlossaryNotFound unless glossary unless glossary.bilingual_pair_exists?(term.source_term, term.target_term) @@ -56,12 +56,16 @@ class UserGlossary < ActiveRecord::Base end def terms(annotation=nil) - glossary = LogalingServer.repository.find_glossary(glossary_name, source_language, target_language) + glossary = find_glossary raise Logaling::GlossaryNotFound unless glossary terms = glossary.terms(annotation).map { |term_hash| Term.set_value(term_hash) } end private + def find_glossary + LogalingServer.repository.find_glossary(glossary_name, source_language, target_language) + end + def create_personal_project! LogalingServer.repository.create_personal_project(glossary_name, source_language, target_language) end -------------- next part -------------- An HTML attachment was scrubbed... 下載