locomotivecms_mounter 1.0.0.alpha2 → 1.0.0.alpha3

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.
@@ -20,7 +20,7 @@ module Locomotive
20
20
  alias :_permalink= :_slug=
21
21
 
22
22
  ## callbacks ##
23
- set_callback :initialize, :after, :set_slug
23
+ # set_callback :initialize, :after, :set_slug
24
24
  set_callback :initialize, :after, :set_default_main_locale
25
25
 
26
26
  ## methods ##
@@ -40,9 +40,6 @@ module Locomotive
40
40
  else
41
41
  value
42
42
  end
43
-
44
- # name = self.content_type.label_field_name
45
- # self.dynamic_getter(name)
46
43
  end
47
44
 
48
45
  # Process a minimal validation by checking if the required fields
@@ -111,7 +108,6 @@ module Locomotive
111
108
  #
112
109
  def dynamic_getter(name)
113
110
  field = self.content_type.find_field(name)
114
-
115
111
  value = self.localized_dynamic_attribute_value(field)
116
112
 
117
113
  case field.type
@@ -270,11 +266,15 @@ module Locomotive
270
266
  # If that attribute is localized and in the current locale
271
267
  # its value is nil, it returns the value in the main locale.
272
268
  #
273
- # @param [ Object ] The content field
269
+ # @param [ String / Object ] The content field or the name of the field
274
270
  #
275
271
  # @return [ Object ] The value
276
272
  #
277
273
  def localized_dynamic_attribute_value(field)
274
+ if field.is_a?(String)
275
+ field = self.content_type.find_field(field)
276
+ end
277
+
278
278
  value = (self.dynamic_attributes || {})[field.name.to_sym]
279
279
 
280
280
  # puts "[#{field.name.inspect}] #{value.inspect} / #{field.localized.inspect} / #{value.is_a?(Hash).inspect}"
@@ -127,12 +127,16 @@ module Locomotive
127
127
  # Find all the entries by a field and its value.
128
128
  #
129
129
  # @param [ String ] name Name of the field
130
- # @param [ String / Array ] value The different value of the field to test
130
+ # @param [ String / Array ] value The different values of the field to test
131
131
  #
132
132
  # @return [ Array ] List of content entries or [] if none
133
133
  #
134
134
  def find_entries_by(name, value)
135
- (self.entries || []).find_all { |entry| [*value].include?(entry.send(name.to_sym)) }
135
+ values = [*value]
136
+ (self.entries || []).find_all do |entry|
137
+ raw_value = entry.send(:localized_dynamic_attribute_value, name)
138
+ values.include?(raw_value)
139
+ end
136
140
  end
137
141
 
138
142
  # Return the params used for the API.
@@ -2,7 +2,7 @@
2
2
  module Locomotive
3
3
  module Mounter #:nodoc
4
4
 
5
- VERSION = '1.0.0.alpha2'
5
+ VERSION = '1.0.0.alpha3'
6
6
 
7
7
  end
8
8
  end
@@ -11,7 +11,9 @@ module Locomotive
11
11
 
12
12
  def write
13
13
  self.open_file('config/translations.yml') do |file|
14
- file.write self.mounting_point.translations.map(&:to_params).to_yaml
14
+ file.write self.mounting_point.translations.inject({}) do |memo,translation|
15
+ memo.merge!(translation.key => translation.values)
16
+ end.to_yaml
15
17
  end
16
18
  end
17
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_mounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha2
4
+ version: 1.0.0.alpha3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
@@ -471,7 +471,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
471
471
  version: '0'
472
472
  segments:
473
473
  - 0
474
- hash: -91950627589408174
474
+ hash: -4474890488804116782
475
475
  required_rubygems_version: !ruby/object:Gem::Requirement
476
476
  none: false
477
477
  requirements: