Module: Arspy::Delegators::ArrayExtensions
- Defined in:
- lib/arspy/delegators/array_extensions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #ap(opts = {}) ⇒ Object
- #la(*args) ⇒ Object
- #lf(*args) ⇒ Object
- #pr(*args) ⇒ Object
- #wi(*args) ⇒ Object
- #wo(*args) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/arspy/delegators/array_extensions.rb', line 4 def self.included(base) base.define_chained_method(:method_missing, :arspy) do |symbol, *args| result = Arspy::Operators.interpret(self, symbol, *args) result = method_missing_without_arspy(symbol, *args) unless result result end base.define_chained_method(:id, :arspy) do return id_without_arspy if (self.empty? || !self.first.is_a?(ActiveRecord::Base)) self.map(&:id) end end |
Instance Method Details
#ap(opts = {}) ⇒ Object
22 23 24 |
# File 'lib/arspy/delegators/array_extensions.rb', line 22 def ap(opts={}) Arspy::Operators.awesome_print(self, opts={}) unless self.empty? end |
#la(*args) ⇒ Object
16 17 18 |
# File 'lib/arspy/delegators/array_extensions.rb', line 16 def la(*args) Arspy::Operators.list_associations(self.first, *args) unless self.emtpy? end |
#lf(*args) ⇒ Object
19 20 21 |
# File 'lib/arspy/delegators/array_extensions.rb', line 19 def lf(*args) Arspy::Operators.list_fields(self.first, *args) unless self.empty? end |
#pr(*args) ⇒ Object
25 26 27 |
# File 'lib/arspy/delegators/array_extensions.rb', line 25 def pr(*args) Arspy::Operators.print_array(self, *args) end |