mongoid-dsl 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/VERSION +1 -1
 - data/lib/mongoid-dsl/fields-ext.rb +59 -9
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 928b2c13156001ffe932ffa4201615a28104110b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e6600e3388d6de69f86435e48b4cdc4c9574da34
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 19438b72f6df2eb261fc584c57f73bb0e1fa7b259d14335f124a0e7882aa5028fbc9f528e921c84c9a081499ac403fa91b1abf18d27db7eefaead3946fefa293
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 94b87661afaefde981345e4c43ae887c5308736b39d80649f33e17df56772dfa54677e6ec6ea692e8d748551d165fae80fbb2f587617cdc3d482d00ef8989dba
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            1. 
     | 
| 
      
 1 
     | 
    
         
            +
            1.2.0
         
     | 
| 
         @@ -187,23 +187,73 @@ end 
     | 
|
| 
       187 
187 
     | 
    
         | 
| 
       188 
188 
     | 
    
         
             
                field.instance_variable_get('@options')[:hidden]= field.instance_variable_get('@options').delete(name_to_use)
         
     | 
| 
       189 
189 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
                 
     | 
| 
      
 190 
     | 
    
         
            +
                if value
         
     | 
| 
      
 191 
     | 
    
         
            +
                  model.instance_eval do
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 194 
     | 
    
         
            +
                      self.class_variable_get(:@@mongoid_dsl_hidden_fields)
         
     | 
| 
      
 195 
     | 
    
         
            +
                    rescue NameError
         
     | 
| 
       191 
196 
     | 
    
         | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
                  rescue NameError
         
     | 
| 
      
 197 
     | 
    
         
            +
                      self.class_variable_set :@@mongoid_dsl_hidden_fields, []
         
     | 
| 
      
 198 
     | 
    
         
            +
                      [:hidden,:hide].each { |sym| scope sym, -> { without(*self.class_variable_get(:@@mongoid_dsl_hidden_fields)) } }
         
     | 
| 
       195 
199 
     | 
    
         | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
      
 200 
     | 
    
         
            +
                      unless default_scoping?
         
     | 
| 
      
 201 
     | 
    
         
            +
                        default_scope -> { hidden }
         
     | 
| 
      
 202 
     | 
    
         
            +
                      end
         
     | 
| 
       198 
203 
     | 
    
         | 
| 
       199 
     | 
    
         
            -
                    unless default_scoping?
         
     | 
| 
       200 
     | 
    
         
            -
                      default_scope -> { hidden }
         
     | 
| 
       201 
204 
     | 
    
         
             
                    end
         
     | 
| 
       202 
205 
     | 
    
         | 
| 
      
 206 
     | 
    
         
            +
                    self.class_variable_get(:@@mongoid_dsl_hidden_fields).push(field.instance_variable_get(:@name)) if !!value
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
       203 
208 
     | 
    
         
             
                  end
         
     | 
| 
      
 209 
     | 
    
         
            +
                end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
              end
         
     | 
| 
      
 212 
     | 
    
         
            +
            end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
            [:index].each do |name_to_use|
         
     | 
| 
      
 215 
     | 
    
         
            +
              Mongoid::Fields.option name_to_use do |model, field, value|
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
                field.instance_variable_get('@options')[:index]= field.instance_variable_get('@options').delete(name_to_use)
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
                if value
         
     | 
| 
      
 220 
     | 
    
         
            +
                  model.instance_eval do
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 223 
     | 
    
         
            +
                      self.class_variable_get(:@@mongoid_dsl_index_fields)
         
     | 
| 
      
 224 
     | 
    
         
            +
                    rescue NameError
         
     | 
| 
      
 225 
     | 
    
         
            +
                      self.class_variable_set :@@mongoid_dsl_index_fields, [{},{}]
         
     | 
| 
      
 226 
     | 
    
         
            +
                    end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                    case
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                      when value.class <= Hash
         
     | 
| 
      
 231 
     | 
    
         
            +
                        self.class_variable_get(:@@mongoid_dsl_index_fields)[0].merge!(value)
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                      when value.class <= Array
         
     | 
| 
      
 234 
     | 
    
         
            +
                        2.times do |index_number|
         
     | 
| 
      
 235 
     | 
    
         
            +
                          if value[index_number].class <= Hash
         
     | 
| 
      
 236 
     | 
    
         
            +
                            self.class_variable_get(:@@mongoid_dsl_index_fields)[index_number].merge!(value[index_number])
         
     | 
| 
      
 237 
     | 
    
         
            +
                          end
         
     | 
| 
      
 238 
     | 
    
         
            +
                        end
         
     | 
| 
       204 
239 
     | 
    
         | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
      
 240 
     | 
    
         
            +
                      when value.class <= TrueClass
         
     | 
| 
      
 241 
     | 
    
         
            +
                        self.class_variable_get(:@@mongoid_dsl_index_fields)[0].merge!(
         
     | 
| 
      
 242 
     | 
    
         
            +
                            {field.instance_variable_get(:@name) => 1}
         
     | 
| 
      
 243 
     | 
    
         
            +
                        )
         
     | 
| 
       206 
244 
     | 
    
         | 
| 
      
 245 
     | 
    
         
            +
                      when value.class <= Numeric && (-1..1).include?(value)
         
     | 
| 
      
 246 
     | 
    
         
            +
                        self.class_variable_get(:@@mongoid_dsl_index_fields)[0].merge!(
         
     | 
| 
      
 247 
     | 
    
         
            +
                            {field.instance_variable_get(:@name) => value}
         
     | 
| 
      
 248 
     | 
    
         
            +
                        )
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                    end
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
                    if self.class_variable_get(:@@mongoid_dsl_index_fields)[0].respond_to?(:empty?) && !self.class_variable_get(:@@mongoid_dsl_index_fields)[0].empty?
         
     | 
| 
      
 253 
     | 
    
         
            +
                      index(*(self.class_variable_get(:@@mongoid_dsl_index_fields).select{|e| e.respond_to?(:empty?) && !e.empty? }))
         
     | 
| 
      
 254 
     | 
    
         
            +
                    end
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
                  end
         
     | 
| 
       207 
257 
     | 
    
         
             
                end
         
     | 
| 
       208 
258 
     | 
    
         | 
| 
       209 
259 
     | 
    
         
             
              end
         
     |