locomotivecms_mounter 1.5.7 → 1.5.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b02502174bb49e4a29cb686853db9f23ff1d14c
4
- data.tar.gz: 9d3007436f0dcb7dfece507a4627d0106b0696bf
3
+ metadata.gz: 5b9591f58b7bda904438efd822c2ef9ff3eb4f6c
4
+ data.tar.gz: 4116d9ab7b296ffd6f3f85b6394e4df46b7f8210
5
5
  SHA512:
6
- metadata.gz: 34cb1bead096ba6dcc49e9df9e60b24ef196ed62789b5cd0ce005a1bf49bec4236311b5ca137877361a456f61e245b852696c86e8f196bd72a33411d0d7e9740
7
- data.tar.gz: c1ae671081b1046eebd8e1f84c9387d97e6abc63c657bb5d55ccdf8c380b236976ddac04aaafc0827de6d74c72a1ca7151d020c14a36225353128297163c0e20
6
+ metadata.gz: f643c0fd06a19a19b4984b9f56ca52fe5c31a30037f9427805191942277c91f2bd1a32ea75bfb825a0ac62ae7051273853e2becdd6bb39be3b520e9bc4e9a7c2
7
+ data.tar.gz: bbb2eb445e409e1f8f884e02f717b7ecad2766692039f479c3828c270847e13ebef5614cf38465fc6be1fd2111240e42d91ff8294e4a15c1ec6bf0bf0a14f4b3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_mounter (1.5.7)
4
+ locomotivecms_mounter (1.5.8)
5
5
  RedCloth (~> 4.2.3)
6
6
  activesupport (~> 3.2.21)
7
7
  chronic (~> 0.10.2)
@@ -80,7 +80,7 @@ GEM
80
80
  rack-test (0.6.2)
81
81
  rack (>= 1.0)
82
82
  rake (0.9.2)
83
- rb-fsevent (0.9.5)
83
+ rb-fsevent (0.9.6)
84
84
  rb-inotify (0.9.5)
85
85
  ffi (>= 0.5.0)
86
86
  ref (1.0.5)
@@ -103,10 +103,29 @@ module Locomotive
103
103
  # @return [ Boolean ] True if it is a dynamic field
104
104
  #
105
105
  def is_dynamic_field?(name)
106
- name = name.to_s.gsub(/\=$/, '').to_sym
106
+ name = find_dynamic_name(name)
107
107
  !self.content_type.try(:find_field, name).nil?
108
108
  end
109
109
 
110
+ # Find the name of a dynamic field from a String
111
+ #
112
+ # Examples:
113
+ # "name" references the name field
114
+ # "name=" references the name field
115
+ # "author_id" references the author field (belongs_to)
116
+ # "article_ids" references the articles field (many_to_many)
117
+ #
118
+ def find_dynamic_name(name)
119
+ name = name.to_s.gsub(/\=$/, '')
120
+
121
+ # _id or _ids (belongs_to or many_to_many)
122
+ if name =~ /(.+)_ids\Z/
123
+ name = $1.pluralize
124
+ end
125
+
126
+ name.to_sym
127
+ end
128
+
110
129
  # Return the value of a dynamic field and cast it depending
111
130
  # on the type of the field (string, date, belongs_to, ...etc).
112
131
  #
@@ -194,7 +213,7 @@ module Locomotive
194
213
  def method_missing(name, *args, &block)
195
214
  if self.is_dynamic_field?(name)
196
215
  if name.to_s.ends_with?('=')
197
- name = name.to_s.gsub(/\=$/, '').to_sym
216
+ name = find_dynamic_name(name)
198
217
  self.dynamic_setter(name, args.first)
199
218
  else
200
219
  self.dynamic_getter(name)
@@ -2,7 +2,7 @@
2
2
  module Locomotive
3
3
  module Mounter #:nodoc
4
4
 
5
- VERSION = '1.5.7'
5
+ VERSION = '1.5.8'
6
6
 
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_mounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -532,7 +532,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
532
532
  version: 1.3.6
533
533
  requirements: []
534
534
  rubyforge_project: locomotivecms_mounter
535
- rubygems_version: 2.4.5
535
+ rubygems_version: 2.2.0
536
536
  signing_key:
537
537
  specification_version: 4
538
538
  summary: LocomotiveCMS Mounter