Module: ActiveScaffold::Tableless::RelationExtension
- Included in:
- Relation
- Defined in:
- lib/active_scaffold/tableless.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
Instance Method Summary collapse
- #except(*skips) ⇒ Object
- #execute_simple_calculation(operation, column_name, distinct) ⇒ Object
- #find_one(id) ⇒ Object
- #initialize(klass, table) ⇒ Object
- #initialize_copy(other) ⇒ Object
- #merge(r) ⇒ Object
- #to_a ⇒ Object
- #where(opts, *rest) ⇒ Object
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
111 112 113 |
# File 'lib/active_scaffold/tableless.rb', line 111 def conditions @conditions end |
Instance Method Details
#except(*skips) ⇒ Object
144 145 146 147 148 |
# File 'lib/active_scaffold/tableless.rb', line 144 def except(*skips) super.tap do |new_relation| new_relation.conditions = conditions unless skips.include? :where end end |
#execute_simple_calculation(operation, column_name, distinct) ⇒ Object
158 159 160 |
# File 'lib/active_scaffold/tableless.rb', line 158 def execute_simple_calculation(operation, column_name, distinct) @klass.execute_simple_calculation(self, operation, column_name, distinct) end |
#find_one(id) ⇒ Object
154 155 156 |
# File 'lib/active_scaffold/tableless.rb', line 154 def find_one(id) @klass.find_one(id, self) || raise(ActiveRecord::RecordNotFound) end |
#initialize(klass, table) ⇒ Object
114 115 116 117 |
# File 'lib/active_scaffold/tableless.rb', line 114 def initialize(klass, table, predicate_builder, values = {}) super @conditions ||= [] end |
#initialize_copy(other) ⇒ Object
125 126 127 128 |
# File 'lib/active_scaffold/tableless.rb', line 125 def initialize_copy(other) @conditions = @conditions.try(:dup) || [] super end |
#merge(r) ⇒ Object
138 139 140 141 142 |
# File 'lib/active_scaffold/tableless.rb', line 138 def merge(r) super.tap do |merged| merged.conditions.concat r.conditions unless r.nil? || r.is_a?(Array) end end |
#to_a ⇒ Object
150 151 152 |
# File 'lib/active_scaffold/tableless.rb', line 150 def to_a @klass.find_all(self) end |
#where(opts, *rest) ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/active_scaffold/tableless.rb', line 130 def where(opts, *rest) if opts.present? opts = opts.with_indifferent_access if opts.is_a? Hash @conditions << (rest.empty? ? opts : [opts, *rest]) end self end |