guilded 1.0.14 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,20 @@
1
1
  module Guilded
2
2
  module Rails
3
-
3
+
4
4
  require 'active_support'
5
5
  #require 'rubygems'
6
6
  #gem 'activesupport', '2.3.2'
7
-
7
+
8
8
  # Common functionality that Rails Guilded components may need to use.
9
9
  #
10
10
  class Helpers
11
-
11
+
12
12
  # Resolves the REST path helper names and arguments from a ActiveRecord object(s).
13
13
  #
14
- def self.resolve_rest_path_helpers( ar_obj_col_or_class, options={} )
15
- if ar_obj_col_or_class.is_a?( Array )
14
+ def self.resolve_rest_path_helpers( ar_obj_col_or_class, options={} )
15
+ if ar_obj_col_or_class.is_a?( ActiveRecord::Relation )
16
+ ar_obj = ar_obj_col_or_class.first
17
+ elsif ar_obj_col_or_class.is_a?( Array )
16
18
  ar_obj = ar_obj_col_or_class[0]
17
19
  elsif ar_obj_col_or_class.is_a?( ActiveRecord::Base )
18
20
  ar_obj = ar_obj_col_or_class
@@ -21,7 +23,7 @@ module Guilded
21
23
  else
22
24
  ar_obj = ar_obj_col_or_class
23
25
  end
24
-
26
+
25
27
  plural_ar_type = ar_obj.class.to_s.tableize
26
28
  singular_ar_type = plural_ar_type.singularize
27
29
  polymorphic_as = options[:polymorphic_as]
@@ -35,12 +37,12 @@ module Guilded
35
37
  scoped_by = Array.new
36
38
  shallow_scoped_by = Array.new
37
39
  helpers = Hash.new
38
-
40
+
39
41
  if options[:namespace]
40
42
  pre << "#{options[:namespace].to_s}_"
41
- shallow_pre << "#{options[:namespace].to_s}_"
43
+ shallow_pre << "#{options[:namespace].to_s}_"
42
44
  end
43
-
45
+
44
46
  if options[:scoped_by]
45
47
  scoped_by = options[:scoped_by].is_a?( Array ) ? options[:scoped_by] : Array.new << options[:scoped_by]
46
48
  scoped_by.each_with_index do |scoper, i|
@@ -51,7 +53,7 @@ module Guilded
51
53
  shallow_scoped_by = scoped_by.clone
52
54
  shallow_scoped_by.pop if options[:shallow]
53
55
  end
54
-
56
+
55
57
  helpers[:index_rest_helper] = "#{pre}#{plural_derived_type}_path"
56
58
  helpers[:index_rest_args] = scoped_by
57
59
  helpers[:show_rest_helper] = "#{shallow_pre}#{singular_derived_type}_path"
@@ -62,10 +64,10 @@ module Guilded
62
64
  helpers[:edit_rest_args] = shallow_scoped_by
63
65
  helpers[:delete_rest_helper] = "delete_#{shallow_pre}#{singular_derived_type}_path"
64
66
  helpers[:delete_rest_args] = shallow_scoped_by
65
-
67
+
66
68
  return helpers
67
69
  end
68
-
70
+
69
71
  # Helper method that generates a path from an item. If item is :home then this method
70
72
  # will call the home_path method to generate a link
71
73
  #
@@ -116,8 +118,8 @@ module Guilded
116
118
 
117
119
  return methods, titles
118
120
  end
119
-
121
+
120
122
  end
121
-
123
+
122
124
  end
123
- end
125
+ end
@@ -1,3 +1,3 @@
1
1
  module Guilded
2
- VERSION = "1.0.14"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guilded
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 14
10
- version: 1.0.14
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Harrelson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-30 00:00:00 -05:00
18
+ date: 2012-01-05 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency