Sha256: 92565d7524f2a4cbc2f5f3aa8f90477d87c4c091c080b99b370d0c85029b8058

Contents?: true

Size: 1.75 KB

Versions: 9

Compression:

Stored size: 1.75 KB

Contents

require 'digest/sha1'
require "uri"

require "not_relational/domain_model.rb"
class Blurb < NotRelational::DomainModel
    
 property :namespace,:string,:is_primary_key=>true
   property :name,:string,:is_primary_key=>true
   property :description , :string  
  
  has_many :BlurbWording,:blurb_id
    
    def Blurb.get(namespace,name)
        Blurb.find([namespace , name])

    end
     def get_wording(language=$language)
         wording=BlurbWording.find([self.name ,self.namespace,language])
           if !wording && language!='en'
            
                return self.get_wording('en')
            
            end
           if !wording
            return  self.name
           end
         return wording.text
     end
     def set_wording(language,text)
        wording=BlurbWording.find([self.name ,self.namespace,language])
         if !wording
            wording=BlurbWording.new
            wording.blurb_name=self.name
            wording.blurb_namespace=self.namespace
            wording.language_id=language
         end
         wording.text=text
         wording.save
         return wording
         
     end
      def Blurb.set_wording(namespace,name,language,text)
         blurb=Blurb.get(namespace,name)
         if !blurb
            blurb=Blurb.new
            blurb.name=name
            blurb.namespace=namespace
            blurb.save!
         end
         blurb.set_wording(language,text)
     end
     
     def Blurb.get_wording(namespace,name,language_id='en',default_value=nil)
       result=BlurbWording.find([name ,namespace,language_id])
      if result!=nil
         return result.text
      end
      if   language_id=='en'
        return default_value || name
      end
     return Blurb.get_wording(namespace,name,'en')
   
     end
   
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cloudwow-not_relational-0.1.0 test/models/blurb.rb
cloudwow-not_relational-0.1.11 test/models/blurb.rb
cloudwow-not_relational-0.1.2 test/models/blurb.rb
cloudwow-not_relational-0.1.3 test/models/blurb.rb
cloudwow-not_relational-0.1.5 test/models/blurb.rb
cloudwow-not_relational-0.1.6 test/models/blurb.rb
cloudwow-not_relational-0.1.7 test/models/blurb.rb
cloudwow-not_relational-0.1.8 test/models/blurb.rb
cloudwow-not_relational-0.1.9 test/models/blurb.rb