Guest User

Untitled

a guest
Apr 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. # for eql and like operators the new value overwrites when merged
  2.  
  3. Article.with_scope :author => 'smoot' do
  4. Article.with_scope :author => 'dkubb' do
  5. # conditions are:
  6. # [ :eql, Property<Article, :author>, 'dkubb' ]
  7. end
  8. end
  9.  
  10. Article.with_scope :author.like => /\Asmoot\z/ do
  11. Article.with_scope :author.like => /\Adkubb\z/ do
  12. # conditions are:
  13. # [ :like, Property<Article, :author>, /\Adkubb\z/ ]
  14. end
  15. end
  16.  
  17. # for gt and gte operators the smallest value is used when merged
  18.  
  19. Item.with_scope :amount.gt => 2.00 do
  20. Item.with_scope :amount.gt => 1.00 do
  21. # conditions are:
  22. # [ :gt, Property<Item, :amount>, 1.00 ]
  23. end
  24. end
  25.  
  26. Item.with_scope :amount.gt => 1.00 do
  27. Item.with_scope :amount.gt => 2.00 do
  28. # conditions are:
  29. # [ :gt, Property<Item, :amount>, 1.00 ] <-- still 1.00
  30. end
  31. end
  32.  
  33. # for lt and lte operators the largest value is used when merged
  34.  
  35. Item.with_scope :amount.lt => 1.00 do
  36. Item.with_scope :amount.lt => 2.00 do
  37. # conditions are:
  38. # [ :lt, Property<Item, :amount>, 2.00 ]
  39. end
  40. end
  41.  
  42. Item.with_scope :amount.lt => 2.00 do
  43. Item.with_scope :amount.lt => 1.00 do
  44. # conditions are:
  45. # [ :lt, Property<Item, :amount>, 2.00 ] <-- still 2.00
  46. end
  47. end
  48.  
  49. # for not and in operators the values are unioned when merged
  50.  
  51. Article.with_scope :author.not => 'billg' do
  52. Article.with_scope :author.not => 'darylm' do
  53. # conditions are:
  54. # [ :not, Property<Article, :author>, [ 'billg', 'darylm' ] ]
  55. end
  56. end
  57.  
  58. Article.with_scope :author.in => 'ssmoot' do
  59. Article.with_scope :author.in => 'dkubb' do
  60. # conditions are:
  61. # [ :in, Property<Article, :author>, [ 'smoot', 'dkubb' ] ]
  62. end
  63. end
Add Comment
Please, Sign In to add comment