tablo_connect 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +43 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/fonts/tablo_connect/bootstrap/glyphicons-halflings-regular.eot +0 -0
  6. data/app/assets/fonts/tablo_connect/bootstrap/glyphicons-halflings-regular.svg +288 -0
  7. data/app/assets/fonts/tablo_connect/bootstrap/glyphicons-halflings-regular.ttf +0 -0
  8. data/app/assets/fonts/tablo_connect/bootstrap/glyphicons-halflings-regular.woff +0 -0
  9. data/app/assets/fonts/tablo_connect/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
  10. data/app/assets/javascripts/tablo_connect/angular/angular-animate.js +3928 -0
  11. data/app/assets/javascripts/tablo_connect/angular/angular-animate.min.js +56 -0
  12. data/app/assets/javascripts/tablo_connect/angular/angular-animate.min.js.map +8 -0
  13. data/app/assets/javascripts/tablo_connect/angular/angular-aria.js +397 -0
  14. data/app/assets/javascripts/tablo_connect/angular/angular-aria.min.js +14 -0
  15. data/app/assets/javascripts/tablo_connect/angular/angular-aria.min.js.map +8 -0
  16. data/app/assets/javascripts/tablo_connect/angular/angular-cookies.js +321 -0
  17. data/app/assets/javascripts/tablo_connect/angular/angular-cookies.min.js +9 -0
  18. data/app/assets/javascripts/tablo_connect/angular/angular-cookies.min.js.map +8 -0
  19. data/app/assets/javascripts/tablo_connect/angular/angular-csp.css +21 -0
  20. data/app/assets/javascripts/tablo_connect/angular/angular-loader.js +443 -0
  21. data/app/assets/javascripts/tablo_connect/angular/angular-loader.min.js +10 -0
  22. data/app/assets/javascripts/tablo_connect/angular/angular-loader.min.js.map +8 -0
  23. data/app/assets/javascripts/tablo_connect/angular/angular-message-format.js +980 -0
  24. data/app/assets/javascripts/tablo_connect/angular/angular-message-format.min.js +26 -0
  25. data/app/assets/javascripts/tablo_connect/angular/angular-message-format.min.js.map +8 -0
  26. data/app/assets/javascripts/tablo_connect/angular/angular-messages.js +685 -0
  27. data/app/assets/javascripts/tablo_connect/angular/angular-messages.min.js +12 -0
  28. data/app/assets/javascripts/tablo_connect/angular/angular-messages.min.js.map +8 -0
  29. data/app/assets/javascripts/tablo_connect/angular/angular-mocks.js +2470 -0
  30. data/app/assets/javascripts/tablo_connect/angular/angular-resource.js +675 -0
  31. data/app/assets/javascripts/tablo_connect/angular/angular-resource.min.js +13 -0
  32. data/app/assets/javascripts/tablo_connect/angular/angular-resource.min.js.map +8 -0
  33. data/app/assets/javascripts/tablo_connect/angular/angular-route.js +991 -0
  34. data/app/assets/javascripts/tablo_connect/angular/angular-route.min.js +15 -0
  35. data/app/assets/javascripts/tablo_connect/angular/angular-route.min.js.map +8 -0
  36. data/app/assets/javascripts/tablo_connect/angular/angular-sanitize.js +683 -0
  37. data/app/assets/javascripts/tablo_connect/angular/angular-sanitize.min.js +16 -0
  38. data/app/assets/javascripts/tablo_connect/angular/angular-sanitize.min.js.map +8 -0
  39. data/app/assets/javascripts/tablo_connect/angular/angular-scenario.js +40324 -0
  40. data/app/assets/javascripts/tablo_connect/angular/angular-touch.js +628 -0
  41. data/app/assets/javascripts/tablo_connect/angular/angular-touch.min.js +13 -0
  42. data/app/assets/javascripts/tablo_connect/angular/angular-touch.min.js.map +8 -0
  43. data/app/assets/javascripts/tablo_connect/angular/angular-ui-router.js +4370 -0
  44. data/app/assets/javascripts/tablo_connect/angular/angular.js +28904 -0
  45. data/app/assets/javascripts/tablo_connect/angular/angular.min.js +294 -0
  46. data/app/assets/javascripts/tablo_connect/angular/angular.min.js.map +8 -0
  47. data/app/assets/javascripts/tablo_connect/angular/errors.json +1 -0
  48. data/app/assets/javascripts/tablo_connect/angular/version.json +1 -0
  49. data/app/assets/javascripts/tablo_connect/angular/version.txt +1 -0
  50. data/app/assets/javascripts/tablo_connect/application.js +21 -0
  51. data/app/assets/javascripts/tablo_connect/bootstrap/affix.js +162 -0
  52. data/app/assets/javascripts/tablo_connect/bootstrap/alert.js +94 -0
  53. data/app/assets/javascripts/tablo_connect/bootstrap/button.js +120 -0
  54. data/app/assets/javascripts/tablo_connect/bootstrap/carousel.js +237 -0
  55. data/app/assets/javascripts/tablo_connect/bootstrap/collapse.js +211 -0
  56. data/app/assets/javascripts/tablo_connect/bootstrap/dropdown.js +165 -0
  57. data/app/assets/javascripts/tablo_connect/bootstrap/modal.js +337 -0
  58. data/app/assets/javascripts/tablo_connect/bootstrap/popover.js +108 -0
  59. data/app/assets/javascripts/tablo_connect/bootstrap/scrollspy.js +172 -0
  60. data/app/assets/javascripts/tablo_connect/bootstrap/tab.js +155 -0
  61. data/app/assets/javascripts/tablo_connect/bootstrap/tooltip.js +514 -0
  62. data/app/assets/javascripts/tablo_connect/bootstrap/transition.js +59 -0
  63. data/app/assets/javascripts/tablo_connect/jquery/jquery.js +9210 -0
  64. data/app/assets/javascripts/tablo_connect/ng_app/app.js +39 -0
  65. data/app/assets/javascripts/tablo_connect/ng_app/controllers/episodes_controller.js +17 -0
  66. data/app/assets/javascripts/tablo_connect/ng_app/controllers/home_controller.js +9 -0
  67. data/app/assets/javascripts/tablo_connect/ng_app/controllers/movies_controller.js +17 -0
  68. data/app/assets/javascripts/tablo_connect/ng_app/controllers/shows_controller.js +9 -0
  69. data/app/assets/javascripts/tablo_connect/ng_app/filters/titleize_filter.js +17 -0
  70. data/app/assets/javascripts/tablo_connect/ng_app/filters/url_filter.js +19 -0
  71. data/app/assets/javascripts/tablo_connect/ng_app/modules/alerts/alerts.js +9 -0
  72. data/app/assets/javascripts/tablo_connect/ng_app/modules/alerts/directives/alerts_directive.js +19 -0
  73. data/app/assets/javascripts/tablo_connect/ng_app/modules/alerts/services/alerts_service.js +22 -0
  74. data/app/assets/javascripts/tablo_connect/ng_app/modules/alerts/templates/alerts.html +6 -0
  75. data/app/assets/javascripts/tablo_connect/ng_app/modules/tablo_sync/directives/tablo_sync_directive.js +31 -0
  76. data/app/assets/javascripts/tablo_connect/ng_app/modules/tablo_sync/services/tablo_sync_service.js +20 -0
  77. data/app/assets/javascripts/tablo_connect/ng_app/modules/tablo_sync/tablo_sync.js +9 -0
  78. data/app/assets/javascripts/tablo_connect/ng_app/modules/tablo_sync/templates/tablo_sync.html +4 -0
  79. data/app/assets/javascripts/tablo_connect/ng_app/services/tablo_service.js +98 -0
  80. data/app/assets/javascripts/tablo_connect/ng_app/templates/episodes.html +36 -0
  81. data/app/assets/javascripts/tablo_connect/ng_app/templates/index.html +3 -0
  82. data/app/assets/javascripts/tablo_connect/ng_app/templates/movies.html +33 -0
  83. data/app/assets/javascripts/tablo_connect/ng_app/templates/shows.html +13 -0
  84. data/app/assets/stylesheets/tablo_connect/_bootstrap.scss +56 -0
  85. data/app/assets/stylesheets/tablo_connect/_global.scss +19 -0
  86. data/app/assets/stylesheets/tablo_connect/_movies.scss +0 -0
  87. data/app/assets/stylesheets/tablo_connect/_shows.scss +30 -0
  88. data/app/assets/stylesheets/tablo_connect/application.scss +18 -0
  89. data/app/assets/stylesheets/tablo_connect/bootstrap/_alerts.scss +73 -0
  90. data/app/assets/stylesheets/tablo_connect/bootstrap/_badges.scss +68 -0
  91. data/app/assets/stylesheets/tablo_connect/bootstrap/_breadcrumbs.scss +26 -0
  92. data/app/assets/stylesheets/tablo_connect/bootstrap/_button-groups.scss +244 -0
  93. data/app/assets/stylesheets/tablo_connect/bootstrap/_buttons.scss +168 -0
  94. data/app/assets/stylesheets/tablo_connect/bootstrap/_carousel.scss +269 -0
  95. data/app/assets/stylesheets/tablo_connect/bootstrap/_close.scss +36 -0
  96. data/app/assets/stylesheets/tablo_connect/bootstrap/_code.scss +69 -0
  97. data/app/assets/stylesheets/tablo_connect/bootstrap/_component-animations.scss +37 -0
  98. data/app/assets/stylesheets/tablo_connect/bootstrap/_dropdowns.scss +216 -0
  99. data/app/assets/stylesheets/tablo_connect/bootstrap/_forms.scss +611 -0
  100. data/app/assets/stylesheets/tablo_connect/bootstrap/_glyphicons.scss +307 -0
  101. data/app/assets/stylesheets/tablo_connect/bootstrap/_grid.scss +84 -0
  102. data/app/assets/stylesheets/tablo_connect/bootstrap/_input-groups.scss +167 -0
  103. data/app/assets/stylesheets/tablo_connect/bootstrap/_jumbotron.scss +52 -0
  104. data/app/assets/stylesheets/tablo_connect/bootstrap/_labels.scss +66 -0
  105. data/app/assets/stylesheets/tablo_connect/bootstrap/_list-group.scss +130 -0
  106. data/app/assets/stylesheets/tablo_connect/bootstrap/_media.scss +66 -0
  107. data/app/assets/stylesheets/tablo_connect/bootstrap/_mixins.scss +40 -0
  108. data/app/assets/stylesheets/tablo_connect/bootstrap/_modals.scss +150 -0
  109. data/app/assets/stylesheets/tablo_connect/bootstrap/_navbar.scss +662 -0
  110. data/app/assets/stylesheets/tablo_connect/bootstrap/_navs.scss +242 -0
  111. data/app/assets/stylesheets/tablo_connect/bootstrap/_normalize.scss +424 -0
  112. data/app/assets/stylesheets/tablo_connect/bootstrap/_pager.scss +54 -0
  113. data/app/assets/stylesheets/tablo_connect/bootstrap/_pagination.scss +89 -0
  114. data/app/assets/stylesheets/tablo_connect/bootstrap/_panels.scss +271 -0
  115. data/app/assets/stylesheets/tablo_connect/bootstrap/_popovers.scss +131 -0
  116. data/app/assets/stylesheets/tablo_connect/bootstrap/_print.scss +101 -0
  117. data/app/assets/stylesheets/tablo_connect/bootstrap/_progress-bars.scss +87 -0
  118. data/app/assets/stylesheets/tablo_connect/bootstrap/_responsive-embed.scss +35 -0
  119. data/app/assets/stylesheets/tablo_connect/bootstrap/_responsive-utilities.scss +179 -0
  120. data/app/assets/stylesheets/tablo_connect/bootstrap/_scaffolding.scss +161 -0
  121. data/app/assets/stylesheets/tablo_connect/bootstrap/_tables.scss +234 -0
  122. data/app/assets/stylesheets/tablo_connect/bootstrap/_theme.scss +291 -0
  123. data/app/assets/stylesheets/tablo_connect/bootstrap/_thumbnails.scss +38 -0
  124. data/app/assets/stylesheets/tablo_connect/bootstrap/_tooltip.scss +101 -0
  125. data/app/assets/stylesheets/tablo_connect/bootstrap/_type.scss +298 -0
  126. data/app/assets/stylesheets/tablo_connect/bootstrap/_utilities.scss +55 -0
  127. data/app/assets/stylesheets/tablo_connect/bootstrap/_variables.scss +872 -0
  128. data/app/assets/stylesheets/tablo_connect/bootstrap/_wells.scss +29 -0
  129. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_alerts.scss +14 -0
  130. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_background-variant.scss +12 -0
  131. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_border-radius.scss +18 -0
  132. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_buttons.scss +68 -0
  133. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_center-block.scss +7 -0
  134. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_clearfix.scss +22 -0
  135. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_forms.scss +88 -0
  136. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_gradients.scss +58 -0
  137. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_grid-framework.scss +81 -0
  138. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_grid.scss +122 -0
  139. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_hide-text.scss +21 -0
  140. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_image.scss +33 -0
  141. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_labels.scss +12 -0
  142. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_list-group.scss +32 -0
  143. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_nav-divider.scss +10 -0
  144. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_nav-vertical-align.scss +9 -0
  145. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_opacity.scss +8 -0
  146. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_pagination.scss +24 -0
  147. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_panels.scss +24 -0
  148. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_progress-bar.scss +10 -0
  149. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_reset-filter.scss +8 -0
  150. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_reset-text.scss +18 -0
  151. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_resize.scss +6 -0
  152. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_responsive-visibility.scss +21 -0
  153. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_size.scss +10 -0
  154. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_tab-focus.scss +9 -0
  155. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_table-row.scss +28 -0
  156. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_text-emphasis.scss +12 -0
  157. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_text-overflow.scss +8 -0
  158. data/app/assets/stylesheets/tablo_connect/bootstrap/mixins/_vendor-prefixes.scss +222 -0
  159. data/app/controllers/tablo_connect/application_controller.rb +4 -0
  160. data/app/controllers/tablo_connect/copy_controller.rb +75 -0
  161. data/app/controllers/tablo_connect/home_controller.rb +6 -0
  162. data/app/controllers/tablo_connect/movies_controller.rb +9 -0
  163. data/app/controllers/tablo_connect/shows_controller.rb +11 -0
  164. data/app/controllers/tablo_connect/sync_controller.rb +73 -0
  165. data/app/helpers/tablo_connect/application_helper.rb +4 -0
  166. data/app/helpers/tablo_connect/movies_helper.rb +4 -0
  167. data/app/helpers/tablo_connect/shows_helper.rb +4 -0
  168. data/app/models/tablo_connect/movie.rb +14 -0
  169. data/app/models/tablo_connect/show.rb +23 -0
  170. data/app/views/layouts/tablo_connect/_header.html.erb +20 -0
  171. data/app/views/layouts/tablo_connect/application.html.erb +19 -0
  172. data/app/views/tablo_connect/home/index.html.erb +1 -0
  173. data/config/routes.rb +10 -0
  174. data/db/migrate/20151101164611_create_tablo_connect_movies.rb +18 -0
  175. data/db/migrate/20151101165020_create_tablo_connect_shows.rb +21 -0
  176. data/lib/tablo_connect.rb +7 -0
  177. data/lib/tablo_connect/engine.rb +28 -0
  178. data/lib/tablo_connect/version.rb +3 -0
  179. data/lib/tasks/tablo_connect_tasks.rake +4 -0
  180. data/spec/controllers/tablo_connect/copy_controller_spec.rb +244 -0
  181. data/spec/controllers/tablo_connect/movies_controller_spec.rb +27 -0
  182. data/spec/controllers/tablo_connect/shows_controller_spec.rb +45 -0
  183. data/spec/controllers/tablo_connect/sync_controller_spec.rb +209 -0
  184. data/spec/factories/tablo_connect_movies.rb +11 -0
  185. data/spec/factories/tablo_connect_shows.rb +15 -0
  186. data/spec/javascript/angular-environment.js +1 -0
  187. data/spec/javascript/karma.conf.js +48 -0
  188. data/spec/javascript/unit/controllers/episodes_controller_spec.js +49 -0
  189. data/spec/javascript/unit/controllers/home_controller_spec.js +34 -0
  190. data/spec/javascript/unit/controllers/movies_controller_spec.js +55 -0
  191. data/spec/javascript/unit/controllers/shows_controller_spec.js +33 -0
  192. data/spec/javascript/unit/filters/titleize_filter_spec.js +25 -0
  193. data/spec/javascript/unit/filters/url_filter_spec.js +33 -0
  194. data/spec/javascript/unit/modules/alerts/directives/alerts_directive_spec.js +39 -0
  195. data/spec/javascript/unit/modules/alerts/services/alerts_service_spec.js +51 -0
  196. data/spec/javascript/unit/modules/tablo_sync/directives/tablo_sync_directive_spec.js +68 -0
  197. data/spec/javascript/unit/modules/tablo_sync/services/tablo_sync_service_spec.js +26 -0
  198. data/spec/javascript/unit/services/tablo_service_spec.js +28 -0
  199. data/spec/models/tablo_connect/movie_spec.rb +32 -0
  200. data/spec/models/tablo_connect/show_spec.rb +65 -0
  201. data/spec/spec_helper.rb +86 -0
  202. data/spec/test_app/README.rdoc +28 -0
  203. data/spec/test_app/Rakefile +6 -0
  204. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  205. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  206. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  207. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  208. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  209. data/spec/test_app/bin/bundle +3 -0
  210. data/spec/test_app/bin/rails +4 -0
  211. data/spec/test_app/bin/rake +4 -0
  212. data/spec/test_app/bin/setup +29 -0
  213. data/spec/test_app/config.ru +4 -0
  214. data/spec/test_app/config/application.rb +32 -0
  215. data/spec/test_app/config/boot.rb +5 -0
  216. data/spec/test_app/config/database.yml +25 -0
  217. data/spec/test_app/config/environment.rb +5 -0
  218. data/spec/test_app/config/environments/development.rb +41 -0
  219. data/spec/test_app/config/environments/production.rb +79 -0
  220. data/spec/test_app/config/environments/test.rb +42 -0
  221. data/spec/test_app/config/initializers/assets.rb +11 -0
  222. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  223. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  224. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  225. data/spec/test_app/config/initializers/inflections.rb +16 -0
  226. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  227. data/spec/test_app/config/initializers/session_store.rb +3 -0
  228. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  229. data/spec/test_app/config/locales/en.yml +23 -0
  230. data/spec/test_app/config/routes.rb +4 -0
  231. data/spec/test_app/config/secrets.yml +22 -0
  232. data/spec/test_app/db/schema.rb +49 -0
  233. data/spec/test_app/db/test.sqlite3 +0 -0
  234. data/spec/test_app/log/test.log +5561 -0
  235. data/spec/test_app/public/404.html +67 -0
  236. data/spec/test_app/public/422.html +67 -0
  237. data/spec/test_app/public/500.html +66 -0
  238. data/spec/test_app/public/favicon.ico +0 -0
  239. metadata +550 -0
@@ -0,0 +1,675 @@
1
+ /**
2
+ * @license AngularJS v1.4.7
3
+ * (c) 2010-2015 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+ (function(window, angular, undefined) {'use strict';
7
+
8
+ var $resourceMinErr = angular.$$minErr('$resource');
9
+
10
+ // Helper functions and regex to lookup a dotted path on an object
11
+ // stopping at undefined/null. The path must be composed of ASCII
12
+ // identifiers (just like $parse)
13
+ var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;
14
+
15
+ function isValidDottedPath(path) {
16
+ return (path != null && path !== '' && path !== 'hasOwnProperty' &&
17
+ MEMBER_NAME_REGEX.test('.' + path));
18
+ }
19
+
20
+ function lookupDottedPath(obj, path) {
21
+ if (!isValidDottedPath(path)) {
22
+ throw $resourceMinErr('badmember', 'Dotted member path "@{0}" is invalid.', path);
23
+ }
24
+ var keys = path.split('.');
25
+ for (var i = 0, ii = keys.length; i < ii && angular.isDefined(obj); i++) {
26
+ var key = keys[i];
27
+ obj = (obj !== null) ? obj[key] : undefined;
28
+ }
29
+ return obj;
30
+ }
31
+
32
+ /**
33
+ * Create a shallow copy of an object and clear other fields from the destination
34
+ */
35
+ function shallowClearAndCopy(src, dst) {
36
+ dst = dst || {};
37
+
38
+ angular.forEach(dst, function(value, key) {
39
+ delete dst[key];
40
+ });
41
+
42
+ for (var key in src) {
43
+ if (src.hasOwnProperty(key) && !(key.charAt(0) === '$' && key.charAt(1) === '$')) {
44
+ dst[key] = src[key];
45
+ }
46
+ }
47
+
48
+ return dst;
49
+ }
50
+
51
+ /**
52
+ * @ngdoc module
53
+ * @name ngResource
54
+ * @description
55
+ *
56
+ * # ngResource
57
+ *
58
+ * The `ngResource` module provides interaction support with RESTful services
59
+ * via the $resource service.
60
+ *
61
+ *
62
+ * <div doc-module-components="ngResource"></div>
63
+ *
64
+ * See {@link ngResource.$resource `$resource`} for usage.
65
+ */
66
+
67
+ /**
68
+ * @ngdoc service
69
+ * @name $resource
70
+ * @requires $http
71
+ *
72
+ * @description
73
+ * A factory which creates a resource object that lets you interact with
74
+ * [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) server-side data sources.
75
+ *
76
+ * The returned resource object has action methods which provide high-level behaviors without
77
+ * the need to interact with the low level {@link ng.$http $http} service.
78
+ *
79
+ * Requires the {@link ngResource `ngResource`} module to be installed.
80
+ *
81
+ * By default, trailing slashes will be stripped from the calculated URLs,
82
+ * which can pose problems with server backends that do not expect that
83
+ * behavior. This can be disabled by configuring the `$resourceProvider` like
84
+ * this:
85
+ *
86
+ * ```js
87
+ app.config(['$resourceProvider', function($resourceProvider) {
88
+ // Don't strip trailing slashes from calculated URLs
89
+ $resourceProvider.defaults.stripTrailingSlashes = false;
90
+ }]);
91
+ * ```
92
+ *
93
+ * @param {string} url A parameterized URL template with parameters prefixed by `:` as in
94
+ * `/user/:username`. If you are using a URL with a port number (e.g.
95
+ * `http://example.com:8080/api`), it will be respected.
96
+ *
97
+ * If you are using a url with a suffix, just add the suffix, like this:
98
+ * `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')`
99
+ * or even `$resource('http://example.com/resource/:resource_id.:format')`
100
+ * If the parameter before the suffix is empty, :resource_id in this case, then the `/.` will be
101
+ * collapsed down to a single `.`. If you need this sequence to appear and not collapse then you
102
+ * can escape it with `/\.`.
103
+ *
104
+ * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in
105
+ * `actions` methods. If any of the parameter value is a function, it will be executed every time
106
+ * when a param value needs to be obtained for a request (unless the param was overridden).
107
+ *
108
+ * Each key value in the parameter object is first bound to url template if present and then any
109
+ * excess keys are appended to the url search query after the `?`.
110
+ *
111
+ * Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
112
+ * URL `/path/greet?salutation=Hello`.
113
+ *
114
+ * If the parameter value is prefixed with `@` then the value for that parameter will be extracted
115
+ * from the corresponding property on the `data` object (provided when calling an action method). For
116
+ * example, if the `defaultParam` object is `{someParam: '@someProp'}` then the value of `someParam`
117
+ * will be `data.someProp`.
118
+ *
119
+ * @param {Object.<Object>=} actions Hash with declaration of custom actions that should extend
120
+ * the default set of resource actions. The declaration should be created in the format of {@link
121
+ * ng.$http#usage $http.config}:
122
+ *
123
+ * {action1: {method:?, params:?, isArray:?, headers:?, ...},
124
+ * action2: {method:?, params:?, isArray:?, headers:?, ...},
125
+ * ...}
126
+ *
127
+ * Where:
128
+ *
129
+ * - **`action`** – {string} – The name of action. This name becomes the name of the method on
130
+ * your resource object.
131
+ * - **`method`** – {string} – Case insensitive HTTP method (e.g. `GET`, `POST`, `PUT`,
132
+ * `DELETE`, `JSONP`, etc).
133
+ * - **`params`** – {Object=} – Optional set of pre-bound parameters for this action. If any of
134
+ * the parameter value is a function, it will be executed every time when a param value needs to
135
+ * be obtained for a request (unless the param was overridden).
136
+ * - **`url`** – {string} – action specific `url` override. The url templating is supported just
137
+ * like for the resource-level urls.
138
+ * - **`isArray`** – {boolean=} – If true then the returned object for this action is an array,
139
+ * see `returns` section.
140
+ * - **`transformRequest`** –
141
+ * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
142
+ * transform function or an array of such functions. The transform function takes the http
143
+ * request body and headers and returns its transformed (typically serialized) version.
144
+ * By default, transformRequest will contain one function that checks if the request data is
145
+ * an object and serializes to using `angular.toJson`. To prevent this behavior, set
146
+ * `transformRequest` to an empty array: `transformRequest: []`
147
+ * - **`transformResponse`** –
148
+ * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
149
+ * transform function or an array of such functions. The transform function takes the http
150
+ * response body and headers and returns its transformed (typically deserialized) version.
151
+ * By default, transformResponse will contain one function that checks if the response looks like
152
+ * a JSON string and deserializes it using `angular.fromJson`. To prevent this behavior, set
153
+ * `transformResponse` to an empty array: `transformResponse: []`
154
+ * - **`cache`** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
155
+ * GET request, otherwise if a cache instance built with
156
+ * {@link ng.$cacheFactory $cacheFactory}, this cache will be used for
157
+ * caching.
158
+ * - **`timeout`** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} that
159
+ * should abort the request when resolved.
160
+ * - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the
161
+ * XHR object. See
162
+ * [requests with credentials](https://developer.mozilla.org/en/http_access_control#section_5)
163
+ * for more information.
164
+ * - **`responseType`** - `{string}` - see
165
+ * [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType).
166
+ * - **`interceptor`** - `{Object=}` - The interceptor object has two optional methods -
167
+ * `response` and `responseError`. Both `response` and `responseError` interceptors get called
168
+ * with `http response` object. See {@link ng.$http $http interceptors}.
169
+ *
170
+ * @param {Object} options Hash with custom settings that should extend the
171
+ * default `$resourceProvider` behavior. The only supported option is
172
+ *
173
+ * Where:
174
+ *
175
+ * - **`stripTrailingSlashes`** – {boolean} – If true then the trailing
176
+ * slashes from any calculated URL will be stripped. (Defaults to true.)
177
+ *
178
+ * @returns {Object} A resource "class" object with methods for the default set of resource actions
179
+ * optionally extended with custom `actions`. The default set contains these actions:
180
+ * ```js
181
+ * { 'get': {method:'GET'},
182
+ * 'save': {method:'POST'},
183
+ * 'query': {method:'GET', isArray:true},
184
+ * 'remove': {method:'DELETE'},
185
+ * 'delete': {method:'DELETE'} };
186
+ * ```
187
+ *
188
+ * Calling these methods invoke an {@link ng.$http} with the specified http method,
189
+ * destination and parameters. When the data is returned from the server then the object is an
190
+ * instance of the resource class. The actions `save`, `remove` and `delete` are available on it
191
+ * as methods with the `$` prefix. This allows you to easily perform CRUD operations (create,
192
+ * read, update, delete) on server-side data like this:
193
+ * ```js
194
+ * var User = $resource('/user/:userId', {userId:'@id'});
195
+ * var user = User.get({userId:123}, function() {
196
+ * user.abc = true;
197
+ * user.$save();
198
+ * });
199
+ * ```
200
+ *
201
+ * It is important to realize that invoking a $resource object method immediately returns an
202
+ * empty reference (object or array depending on `isArray`). Once the data is returned from the
203
+ * server the existing reference is populated with the actual data. This is a useful trick since
204
+ * usually the resource is assigned to a model which is then rendered by the view. Having an empty
205
+ * object results in no rendering, once the data arrives from the server then the object is
206
+ * populated with the data and the view automatically re-renders itself showing the new data. This
207
+ * means that in most cases one never has to write a callback function for the action methods.
208
+ *
209
+ * The action methods on the class object or instance object can be invoked with the following
210
+ * parameters:
211
+ *
212
+ * - HTTP GET "class" actions: `Resource.action([parameters], [success], [error])`
213
+ * - non-GET "class" actions: `Resource.action([parameters], postData, [success], [error])`
214
+ * - non-GET instance actions: `instance.$action([parameters], [success], [error])`
215
+ *
216
+ *
217
+ * Success callback is called with (value, responseHeaders) arguments, where the value is
218
+ * the populated resource instance or collection object. The error callback is called
219
+ * with (httpResponse) argument.
220
+ *
221
+ * Class actions return empty instance (with additional properties below).
222
+ * Instance actions return promise of the action.
223
+ *
224
+ * The Resource instances and collection have these additional properties:
225
+ *
226
+ * - `$promise`: the {@link ng.$q promise} of the original server interaction that created this
227
+ * instance or collection.
228
+ *
229
+ * On success, the promise is resolved with the same resource instance or collection object,
230
+ * updated with data from server. This makes it easy to use in
231
+ * {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view
232
+ * rendering until the resource(s) are loaded.
233
+ *
234
+ * On failure, the promise is resolved with the {@link ng.$http http response} object, without
235
+ * the `resource` property.
236
+ *
237
+ * If an interceptor object was provided, the promise will instead be resolved with the value
238
+ * returned by the interceptor.
239
+ *
240
+ * - `$resolved`: `true` after first server interaction is completed (either with success or
241
+ * rejection), `false` before that. Knowing if the Resource has been resolved is useful in
242
+ * data-binding.
243
+ *
244
+ * @example
245
+ *
246
+ * # Credit card resource
247
+ *
248
+ * ```js
249
+ // Define CreditCard class
250
+ var CreditCard = $resource('/user/:userId/card/:cardId',
251
+ {userId:123, cardId:'@id'}, {
252
+ charge: {method:'POST', params:{charge:true}}
253
+ });
254
+
255
+ // We can retrieve a collection from the server
256
+ var cards = CreditCard.query(function() {
257
+ // GET: /user/123/card
258
+ // server returns: [ {id:456, number:'1234', name:'Smith'} ];
259
+
260
+ var card = cards[0];
261
+ // each item is an instance of CreditCard
262
+ expect(card instanceof CreditCard).toEqual(true);
263
+ card.name = "J. Smith";
264
+ // non GET methods are mapped onto the instances
265
+ card.$save();
266
+ // POST: /user/123/card/456 {id:456, number:'1234', name:'J. Smith'}
267
+ // server returns: {id:456, number:'1234', name: 'J. Smith'};
268
+
269
+ // our custom method is mapped as well.
270
+ card.$charge({amount:9.99});
271
+ // POST: /user/123/card/456?amount=9.99&charge=true {id:456, number:'1234', name:'J. Smith'}
272
+ });
273
+
274
+ // we can create an instance as well
275
+ var newCard = new CreditCard({number:'0123'});
276
+ newCard.name = "Mike Smith";
277
+ newCard.$save();
278
+ // POST: /user/123/card {number:'0123', name:'Mike Smith'}
279
+ // server returns: {id:789, number:'0123', name: 'Mike Smith'};
280
+ expect(newCard.id).toEqual(789);
281
+ * ```
282
+ *
283
+ * The object returned from this function execution is a resource "class" which has "static" method
284
+ * for each action in the definition.
285
+ *
286
+ * Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and
287
+ * `headers`.
288
+ * When the data is returned from the server then the object is an instance of the resource type and
289
+ * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD
290
+ * operations (create, read, update, delete) on server-side data.
291
+
292
+ ```js
293
+ var User = $resource('/user/:userId', {userId:'@id'});
294
+ User.get({userId:123}, function(user) {
295
+ user.abc = true;
296
+ user.$save();
297
+ });
298
+ ```
299
+ *
300
+ * It's worth noting that the success callback for `get`, `query` and other methods gets passed
301
+ * in the response that came from the server as well as $http header getter function, so one
302
+ * could rewrite the above example and get access to http headers as:
303
+ *
304
+ ```js
305
+ var User = $resource('/user/:userId', {userId:'@id'});
306
+ User.get({userId:123}, function(u, getResponseHeaders){
307
+ u.abc = true;
308
+ u.$save(function(u, putResponseHeaders) {
309
+ //u => saved user object
310
+ //putResponseHeaders => $http header getter
311
+ });
312
+ });
313
+ ```
314
+ *
315
+ * You can also access the raw `$http` promise via the `$promise` property on the object returned
316
+ *
317
+ ```
318
+ var User = $resource('/user/:userId', {userId:'@id'});
319
+ User.get({userId:123})
320
+ .$promise.then(function(user) {
321
+ $scope.user = user;
322
+ });
323
+ ```
324
+
325
+ * # Creating a custom 'PUT' request
326
+ * In this example we create a custom method on our resource to make a PUT request
327
+ * ```js
328
+ * var app = angular.module('app', ['ngResource', 'ngRoute']);
329
+ *
330
+ * // Some APIs expect a PUT request in the format URL/object/ID
331
+ * // Here we are creating an 'update' method
332
+ * app.factory('Notes', ['$resource', function($resource) {
333
+ * return $resource('/notes/:id', null,
334
+ * {
335
+ * 'update': { method:'PUT' }
336
+ * });
337
+ * }]);
338
+ *
339
+ * // In our controller we get the ID from the URL using ngRoute and $routeParams
340
+ * // We pass in $routeParams and our Notes factory along with $scope
341
+ * app.controller('NotesCtrl', ['$scope', '$routeParams', 'Notes',
342
+ function($scope, $routeParams, Notes) {
343
+ * // First get a note object from the factory
344
+ * var note = Notes.get({ id:$routeParams.id });
345
+ * $id = note.id;
346
+ *
347
+ * // Now call update passing in the ID first then the object you are updating
348
+ * Notes.update({ id:$id }, note);
349
+ *
350
+ * // This will PUT /notes/ID with the note object in the request payload
351
+ * }]);
352
+ * ```
353
+ */
354
+ angular.module('ngResource', ['ng']).
355
+ provider('$resource', function() {
356
+ var PROTOCOL_AND_DOMAIN_REGEX = /^https?:\/\/[^\/]*/;
357
+ var provider = this;
358
+
359
+ this.defaults = {
360
+ // Strip slashes by default
361
+ stripTrailingSlashes: true,
362
+
363
+ // Default actions configuration
364
+ actions: {
365
+ 'get': {method: 'GET'},
366
+ 'save': {method: 'POST'},
367
+ 'query': {method: 'GET', isArray: true},
368
+ 'remove': {method: 'DELETE'},
369
+ 'delete': {method: 'DELETE'}
370
+ }
371
+ };
372
+
373
+ this.$get = ['$http', '$q', function($http, $q) {
374
+
375
+ var noop = angular.noop,
376
+ forEach = angular.forEach,
377
+ extend = angular.extend,
378
+ copy = angular.copy,
379
+ isFunction = angular.isFunction;
380
+
381
+ /**
382
+ * We need our custom method because encodeURIComponent is too aggressive and doesn't follow
383
+ * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set
384
+ * (pchar) allowed in path segments:
385
+ * segment = *pchar
386
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
387
+ * pct-encoded = "%" HEXDIG HEXDIG
388
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
389
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
390
+ * / "*" / "+" / "," / ";" / "="
391
+ */
392
+ function encodeUriSegment(val) {
393
+ return encodeUriQuery(val, true).
394
+ replace(/%26/gi, '&').
395
+ replace(/%3D/gi, '=').
396
+ replace(/%2B/gi, '+');
397
+ }
398
+
399
+
400
+ /**
401
+ * This method is intended for encoding *key* or *value* parts of query component. We need a
402
+ * custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't
403
+ * have to be encoded per http://tools.ietf.org/html/rfc3986:
404
+ * query = *( pchar / "/" / "?" )
405
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
406
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
407
+ * pct-encoded = "%" HEXDIG HEXDIG
408
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
409
+ * / "*" / "+" / "," / ";" / "="
410
+ */
411
+ function encodeUriQuery(val, pctEncodeSpaces) {
412
+ return encodeURIComponent(val).
413
+ replace(/%40/gi, '@').
414
+ replace(/%3A/gi, ':').
415
+ replace(/%24/g, '$').
416
+ replace(/%2C/gi, ',').
417
+ replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
418
+ }
419
+
420
+ function Route(template, defaults) {
421
+ this.template = template;
422
+ this.defaults = extend({}, provider.defaults, defaults);
423
+ this.urlParams = {};
424
+ }
425
+
426
+ Route.prototype = {
427
+ setUrlParams: function(config, params, actionUrl) {
428
+ var self = this,
429
+ url = actionUrl || self.template,
430
+ val,
431
+ encodedVal,
432
+ protocolAndDomain = '';
433
+
434
+ var urlParams = self.urlParams = {};
435
+ forEach(url.split(/\W/), function(param) {
436
+ if (param === 'hasOwnProperty') {
437
+ throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name.");
438
+ }
439
+ if (!(new RegExp("^\\d+$").test(param)) && param &&
440
+ (new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) {
441
+ urlParams[param] = true;
442
+ }
443
+ });
444
+ url = url.replace(/\\:/g, ':');
445
+ url = url.replace(PROTOCOL_AND_DOMAIN_REGEX, function(match) {
446
+ protocolAndDomain = match;
447
+ return '';
448
+ });
449
+
450
+ params = params || {};
451
+ forEach(self.urlParams, function(_, urlParam) {
452
+ val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam];
453
+ if (angular.isDefined(val) && val !== null) {
454
+ encodedVal = encodeUriSegment(val);
455
+ url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) {
456
+ return encodedVal + p1;
457
+ });
458
+ } else {
459
+ url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function(match,
460
+ leadingSlashes, tail) {
461
+ if (tail.charAt(0) == '/') {
462
+ return tail;
463
+ } else {
464
+ return leadingSlashes + tail;
465
+ }
466
+ });
467
+ }
468
+ });
469
+
470
+ // strip trailing slashes and set the url (unless this behavior is specifically disabled)
471
+ if (self.defaults.stripTrailingSlashes) {
472
+ url = url.replace(/\/+$/, '') || '/';
473
+ }
474
+
475
+ // then replace collapse `/.` if found in the last URL path segment before the query
476
+ // E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x`
477
+ url = url.replace(/\/\.(?=\w+($|\?))/, '.');
478
+ // replace escaped `/\.` with `/.`
479
+ config.url = protocolAndDomain + url.replace(/\/\\\./, '/.');
480
+
481
+
482
+ // set params - delegate param encoding to $http
483
+ forEach(params, function(value, key) {
484
+ if (!self.urlParams[key]) {
485
+ config.params = config.params || {};
486
+ config.params[key] = value;
487
+ }
488
+ });
489
+ }
490
+ };
491
+
492
+
493
+ function resourceFactory(url, paramDefaults, actions, options) {
494
+ var route = new Route(url, options);
495
+
496
+ actions = extend({}, provider.defaults.actions, actions);
497
+
498
+ function extractParams(data, actionParams) {
499
+ var ids = {};
500
+ actionParams = extend({}, paramDefaults, actionParams);
501
+ forEach(actionParams, function(value, key) {
502
+ if (isFunction(value)) { value = value(); }
503
+ ids[key] = value && value.charAt && value.charAt(0) == '@' ?
504
+ lookupDottedPath(data, value.substr(1)) : value;
505
+ });
506
+ return ids;
507
+ }
508
+
509
+ function defaultResponseInterceptor(response) {
510
+ return response.resource;
511
+ }
512
+
513
+ function Resource(value) {
514
+ shallowClearAndCopy(value || {}, this);
515
+ }
516
+
517
+ Resource.prototype.toJSON = function() {
518
+ var data = extend({}, this);
519
+ delete data.$promise;
520
+ delete data.$resolved;
521
+ return data;
522
+ };
523
+
524
+ forEach(actions, function(action, name) {
525
+ var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method);
526
+
527
+ Resource[name] = function(a1, a2, a3, a4) {
528
+ var params = {}, data, success, error;
529
+
530
+ /* jshint -W086 */ /* (purposefully fall through case statements) */
531
+ switch (arguments.length) {
532
+ case 4:
533
+ error = a4;
534
+ success = a3;
535
+ //fallthrough
536
+ case 3:
537
+ case 2:
538
+ if (isFunction(a2)) {
539
+ if (isFunction(a1)) {
540
+ success = a1;
541
+ error = a2;
542
+ break;
543
+ }
544
+
545
+ success = a2;
546
+ error = a3;
547
+ //fallthrough
548
+ } else {
549
+ params = a1;
550
+ data = a2;
551
+ success = a3;
552
+ break;
553
+ }
554
+ case 1:
555
+ if (isFunction(a1)) success = a1;
556
+ else if (hasBody) data = a1;
557
+ else params = a1;
558
+ break;
559
+ case 0: break;
560
+ default:
561
+ throw $resourceMinErr('badargs',
562
+ "Expected up to 4 arguments [params, data, success, error], got {0} arguments",
563
+ arguments.length);
564
+ }
565
+ /* jshint +W086 */ /* (purposefully fall through case statements) */
566
+
567
+ var isInstanceCall = this instanceof Resource;
568
+ var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data));
569
+ var httpConfig = {};
570
+ var responseInterceptor = action.interceptor && action.interceptor.response ||
571
+ defaultResponseInterceptor;
572
+ var responseErrorInterceptor = action.interceptor && action.interceptor.responseError ||
573
+ undefined;
574
+
575
+ forEach(action, function(value, key) {
576
+ if (key != 'params' && key != 'isArray' && key != 'interceptor') {
577
+ httpConfig[key] = copy(value);
578
+ }
579
+ });
580
+
581
+ if (hasBody) httpConfig.data = data;
582
+ route.setUrlParams(httpConfig,
583
+ extend({}, extractParams(data, action.params || {}), params),
584
+ action.url);
585
+
586
+ var promise = $http(httpConfig).then(function(response) {
587
+ var data = response.data,
588
+ promise = value.$promise;
589
+
590
+ if (data) {
591
+ // Need to convert action.isArray to boolean in case it is undefined
592
+ // jshint -W018
593
+ if (angular.isArray(data) !== (!!action.isArray)) {
594
+ throw $resourceMinErr('badcfg',
595
+ 'Error in resource configuration for action `{0}`. Expected response to ' +
596
+ 'contain an {1} but got an {2} (Request: {3} {4})', name, action.isArray ? 'array' : 'object',
597
+ angular.isArray(data) ? 'array' : 'object', httpConfig.method, httpConfig.url);
598
+ }
599
+ // jshint +W018
600
+ if (action.isArray) {
601
+ value.length = 0;
602
+ forEach(data, function(item) {
603
+ if (typeof item === "object") {
604
+ value.push(new Resource(item));
605
+ } else {
606
+ // Valid JSON values may be string literals, and these should not be converted
607
+ // into objects. These items will not have access to the Resource prototype
608
+ // methods, but unfortunately there
609
+ value.push(item);
610
+ }
611
+ });
612
+ } else {
613
+ shallowClearAndCopy(data, value);
614
+ value.$promise = promise;
615
+ }
616
+ }
617
+
618
+ value.$resolved = true;
619
+
620
+ response.resource = value;
621
+
622
+ return response;
623
+ }, function(response) {
624
+ value.$resolved = true;
625
+
626
+ (error || noop)(response);
627
+
628
+ return $q.reject(response);
629
+ });
630
+
631
+ promise = promise.then(
632
+ function(response) {
633
+ var value = responseInterceptor(response);
634
+ (success || noop)(value, response.headers);
635
+ return value;
636
+ },
637
+ responseErrorInterceptor);
638
+
639
+ if (!isInstanceCall) {
640
+ // we are creating instance / collection
641
+ // - set the initial promise
642
+ // - return the instance / collection
643
+ value.$promise = promise;
644
+ value.$resolved = false;
645
+
646
+ return value;
647
+ }
648
+
649
+ // instance call
650
+ return promise;
651
+ };
652
+
653
+
654
+ Resource.prototype['$' + name] = function(params, success, error) {
655
+ if (isFunction(params)) {
656
+ error = success; success = params; params = {};
657
+ }
658
+ var result = Resource[name].call(this, params, this, success, error);
659
+ return result.$promise || result;
660
+ };
661
+ });
662
+
663
+ Resource.bind = function(additionalParamDefaults) {
664
+ return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions);
665
+ };
666
+
667
+ return Resource;
668
+ }
669
+
670
+ return resourceFactory;
671
+ }];
672
+ });
673
+
674
+
675
+ })(window, window.angular);