Module: Susanin

Extended by:
ActiveSupport::Concern
Defined in:
lib/susanin.rb,
lib/susanin/pattern.rb,
lib/susanin/version.rb,
lib/susanin/resource.rb

Defined Under Namespace

Modules: ClassMethods Classes: Pattern, Resource

Constant Summary collapse

VERSION =
"0.1"

Instance Method Summary collapse

Instance Method Details

#polymorphic_path(record_or_hash_or_array, options = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/susanin.rb', line 37

def polymorphic_path(record_or_hash_or_array, options={})
  params = susanin_converter(record_or_hash_or_array, options)

  if (params.first.size == 1) && params.first[0].is_a?(String)
    params.first.first
  else
    super(*params)
  end
end

#polymorphic_url(record_or_hash_or_array, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/susanin.rb', line 27

def polymorphic_url(record_or_hash_or_array, options={})
  params = susanin_converter(record_or_hash_or_array, options)

  if (params.first.size == 1) && params.first[0].is_a?(String)
    params.first.first
  else
    super(*params)
  end
end

#susaninObject



53
54
55
# File 'lib/susanin.rb', line 53

def susanin
  @susanin ||= Resource.new()
end

#susanin_converter(record_or_hash_or_array, options = {}) ⇒ Object



47
48
49
50
51
# File 'lib/susanin.rb', line 47

def susanin_converter(record_or_hash_or_array, options={})
  params = susanin.url_parameters(Array.wrap(record_or_hash_or_array))
  params_options = params.extract_options!
  [params, options.merge(params_options)]
end