Module: Sequel::Plugins::ArMethods::ClassMethods
- Defined in:
- lib/clevic/ar_methods.rb
Instance Method Summary collapse
- #count_ar(*args) ⇒ Object
- #find_ar(*args) ⇒ Object
-
#inherited(subclass) ⇒ Object
Copy the necessary class instance variables to the subclass.
- #translate(options) ⇒ Object
Instance Method Details
#count_ar(*args) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/clevic/ar_methods.rb', line 117 def count_ar( *args ) = args. attribute = args.first dataset = dataset.translate( ) unless attribute.nil? dataset = dataset.select( attribute ) end dataset.count end |
#find_ar(*args) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/clevic/ar_methods.rb', line 92 def find_ar( *args ) # copied from ActiveRecord::Base.find = args. #~ validate_find_options(options) #~ set_readonly_option!(options) case args.first when :first dataset.translate().first when :last dataset.translate().last when :all dataset.translate().all else if args.size == 1 dataset.translate().filter( :id.qualify( table_name ) => args.first ).first else dataset.translate().filter( :id.qualify( table_name ) => args ).all end end end |
#inherited(subclass) ⇒ Object
Copy the necessary class instance variables to the subclass.
84 85 86 |
# File 'lib/clevic/ar_methods.rb', line 84 def inherited(subclass) super end |
#translate(options) ⇒ Object
88 89 90 |
# File 'lib/clevic/ar_methods.rb', line 88 def translate( ) dataset.translate( ) end |