Module: ActiveRecord::Acts::ActsAsReadonlyable::ClassMethods::FinderClassOverrides
- Defined in:
- lib/acts_as_readonlyable.rb
Instance Method Summary collapse
- #construct_finder_sql(options) ⇒ Object
- #count_by_sql(sql, options = nil) ⇒ Object
- #find_by_sql(sql, options = nil) ⇒ Object
- #find_every(options) ⇒ Object
-
#set_readonly_option!(options) ⇒ Object
:nodoc:.
Instance Method Details
#construct_finder_sql(options) ⇒ Object
73 74 75 |
# File 'lib/acts_as_readonlyable.rb', line 73 def construct_finder_sql() .merge(:sql => super) end |
#count_by_sql(sql, options = nil) ⇒ Object
69 70 71 |
# File 'lib/acts_as_readonlyable.rb', line 69 def count_by_sql(sql, = nil) run_on_db() { super(sql) } end |
#find_by_sql(sql, options = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/acts_as_readonlyable.rb', line 57 def find_by_sql(sql, = nil) # Called through construct_finder_sql if sql.is_a?(Hash) = sql sql = sql[:sql] end run_on_db() { super(sql) } end |
#find_every(options) ⇒ Object
53 54 55 |
# File 'lib/acts_as_readonlyable.rb', line 53 def find_every() run_on_db() { super } end |
#set_readonly_option!(options) ⇒ Object
:nodoc:
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/acts_as_readonlyable.rb', line 77 def set_readonly_option!() #:nodoc: # Inherit :readonly from finder scope if set. Otherwise, # if :joins is not blank then :readonly defaults to true. unless .has_key?(:readonly) if scoped?(:find, :readonly) [:readonly] = true if scope(:find, :readonly) elsif ![:joins].blank? && ![:select] [:readonly] = true end end end |