Class: DataMapper::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-restful-adapter/adapter.rb

Instance Method Summary collapse

Instance Method Details

#fix_array_param_key(key, value) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/dm-restful-adapter/adapter.rb', line 64

def fix_array_param_key(key, value)
  if Array === value
    ["#{key}[]", value]
  else
    [key, value]
  end
end

#paramsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dm-restful-adapter/adapter.rb', line 49

def params
  options.inject({}) do |hash, (k,v)|
    k = case k
    when DataMapper::Query::Operator
      [k.target, '.', k.operator].join
     when DataMapper::Property::Serial
       k.name
    else
      k
    end
    k,v = fix_array_param_key(k,v)
    hash.merge(k => v)
  end
end