Sha256: 06f3cb5a8fc59533e521341bf003a9224c8922d32cb2e539f90a707c37e030a4
Contents?: true
Size: 567 Bytes
Versions: 1
Compression:
Stored size: 567 Bytes
Contents
module Githu3 module Relations def has_many m, opts={} opts[:class_name] ||= m.to_s.singularize define_method(m) do |*args| params = args.extract_options! klass = Githu3.const_get(opts[:class_name].to_s.camelize) _resource_path = [opts[:nested_in], m].compact.join("/") if args.length == 1 klass.new([path, _resource_path, args.first].join("/"), @client) else Githu3::ResourceCollection.new(@client, klass, [path, _resource_path].join("/"), params) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
githu3-0.0.3 | lib/githu3/relations.rb |