Sha256: d6b1eee1e172db9ef189daa9788e5e639e4d20f89ad6126641a9942ad3bfaab4

Contents?: true

Size: 726 Bytes

Versions: 23

Compression:

Stored size: 726 Bytes

Contents

# Add support for type metadata to arrays

require 'will_paginate/array'

class Array

  attr_accessor :member_class, :origin, :origin_attribute

  def to_url_path
    base_path = origin.try.to_url_path
    "#{base_path}/#{origin_attribute}" unless base_path.blank?
  end

  def typed_id
    origin and origin_id = origin.try.typed_id and "#{origin_id}:#{origin_attribute}"
  end

  def paginate_with_hobo_metadata(*args, &block)
    collection = paginate_without_hobo_metadata(*args, &block)
    collection.member_class     = member_class
    collection.origin           = try.proxy_owner
    collection.origin_attribute = try.proxy_reflection._?.name
    collection
  end
  alias_method_chain :paginate, :hobo_metadata

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
hobo-1.3.3 lib/hobo/extensions/array.rb
hobo-1.3.2 lib/hobo/extensions/array.rb
hobo-1.3.1 lib/hobo/extensions/array.rb
hobo-1.4.0.pre7 lib/hobo/extensions/array.rb
hobo-1.4.0.pre6 lib/hobo/extensions/array.rb
hobo-1.4.0.pre5 lib/hobo/extensions/array.rb
hobo-1.4.0.pre4 lib/hobo/extensions/array.rb
hobo-1.4.0.pre3 lib/hobo/extensions/array.rb
hobo-1.4.0.pre2 lib/hobo/extensions/array.rb
hobo-1.3.0 lib/hobo/extensions/array.rb
hobo-1.3.0.RC4 lib/hobo/extensions/array.rb
hobo-1.3.0.RC3 lib/hobo/extensions/array.rb
hobo-1.3.0.RC2 lib/hobo/extensions/array.rb
hobo-1.3.0.RC1 lib/hobo/extensions/array.rb
hobo-1.3.0.RC lib/hobo/extensions/array.rb
hobo-1.3.0.pre31 lib/hobo/extensions/array.rb
hobo-1.3.0.pre29 lib/hobo/extensions/array.rb
hobo-1.3.0.pre28 lib/hobo/extensions/array.rb
hobo-1.3.0.pre27 lib/hobo/extensions/array.rb
hobo-1.3.0.pre26 lib/hobo/extensions/array.rb