Module: ActiveRecord::Acts::ActsAsReadonlyable::ClassMethods::FinderClassOverrides
- Defined in:
- lib/acts_as_readonlyable.rb
Instance Method Summary collapse
- #calculate(operation, column_name, options = {}) ⇒ Object
- #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
#calculate(operation, column_name, options = {}) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/acts_as_readonlyable.rb', line 96 def calculate(operation, column_name, = {}) run_on_db() do .delete(:readonly) super end end |
#construct_finder_sql(options) ⇒ Object
80 81 82 |
# File 'lib/acts_as_readonlyable.rb', line 80 def construct_finder_sql() .merge(:sql => super) end |
#count_by_sql(sql, options = nil) ⇒ Object
76 77 78 |
# File 'lib/acts_as_readonlyable.rb', line 76 def count_by_sql(sql, = nil) run_on_db() { super(sql) } end |
#find_by_sql(sql, options = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/acts_as_readonlyable.rb', line 64 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
60 61 62 |
# File 'lib/acts_as_readonlyable.rb', line 60 def find_every() run_on_db() { super } end |
#set_readonly_option!(options) ⇒ Object
:nodoc:
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/acts_as_readonlyable.rb', line 84 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 |