Class: ActiveRecordEx::ManyToMany::ModelArel
- Inherits:
-
ActiveRecord::Relation
- Object
- ActiveRecord::Relation
- ActiveRecordEx::ManyToMany::ModelArel
- Defined in:
- lib/active-record-ex/many_to_many.rb
Instance Method Summary collapse
-
#initialize(model) ⇒ ModelArel
constructor
A new instance of ModelArel.
- #pluck(key) ⇒ Object
- #reset ⇒ Object
Methods inherited from ActiveRecord::Relation
#disjunct, #none, #relative_complement, #where_only
Constructor Details
#initialize(model) ⇒ ModelArel
Returns a new instance of ModelArel.
7 8 9 10 11 |
# File 'lib/active-record-ex/many_to_many.rb', line 7 def initialize(model) super(model.class, model.class.arel_table) @loaded = true @records = [model] end |
Instance Method Details
#pluck(key) ⇒ Object
18 19 20 21 |
# File 'lib/active-record-ex/many_to_many.rb', line 18 def pluck(key) key = key.name if key.respond_to? :name @records.map(&:"#{key}") end |
#reset ⇒ Object
13 14 15 16 |
# File 'lib/active-record-ex/many_to_many.rb', line 13 def reset # reset says "my currently loaded into memory models no longer currently represent this relation". # That's never true for a ModelArel, so we no-op end |