motion-prime 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Nzg0M2M3MWY1OWZhOTU1NDkwOWY3MzllNTY1NTJlZDc3YWY1ZDg5Yw==
4
+ Yzc2NmYzMWIzZTRkOTA3ODFjZjc0NTdkYWM0ZmVjMTQ0OTU1OGM4Yw==
5
5
  data.tar.gz: !binary |-
6
- ZjAxODM0OTk4NDg1NGMwMTE1OGZlYTI2NTc5NTVjMmNiZmJiZDQxZA==
6
+ YWUzZWRiOTRjMmQyOTcyYzQzMjFhZWY4YzM0MDY0MzYwZDkzZThlOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTQzYjI2NDYxMmNjY2Y1ZmQxMGZjOWI2ZTUyMGQ3YmE3ZWM5MjBhMzU3YjUy
10
- Y2RlZWU2ZmVlYmZhNzhjNmMyYTU3ZDhlYTkyYWQzNjhhYzhjNjU3YTJlNzBm
11
- NzI2OTc1MWM0ZGU1ZWNiYjE3MjMzYTU2YTFkZjNmMzE0ODJmMzI=
9
+ ZDNhMTg1MmYxYjhkMTE3MTAzMjAyY2M0NjAzODE4Mjc0ZjZmOTIxMzNkNmQ3
10
+ Y2Q2MTlmNmYzMGI5YWE5YjExZmUwNWE3N2FkNWY2YzNmMmI5ZDU4OTliZDI2
11
+ MzUxMzg5NGVmMWVkMjk0MDQxYjlmZWY2OGYzYzUzNGJjMjcyNTk=
12
12
  data.tar.gz: !binary |-
13
- OTM5NTA1YjlhNmQ1NTZlN2M4MWQ5ODhkNTEwYmM1ZDBlOTQ3MmFhMjRkZTRk
14
- OWFiY2M4OWZlZTU4Y2UyNjk2MWNiNmQ3MGJlMWMxOTBjNzI3OWNkOGQ1YWVl
15
- Mzg0MTFlZTI5YTU1YzYyMjRkZGY0MmNmMDJjMzJiMjBiMDg4OTM=
13
+ YmI1OTU0YTVjYjE1NDY3MzJkMGMwZmJkOGVlZGVlOGJlZTllNjA1ODVjMzg1
14
+ YWUxMDlhOGE1N2Q2YTY1ODVlNjhiYjVmOGUwN2JmYjYxYjJmZjg2MWU1ZTBi
15
+ NTMwM2YwYTFkOGRmNmU1NjJhNDc5NjNiYzZmODk3ZTYzYzE2OTA=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ === 0.1.6
2
+ * Section container options now support proc values
3
+
1
4
  === 0.1.5
2
5
  * MP::FormSection#on_edit renamed to on_input_edit
3
6
  * MP::FormSection#on_input_change callback added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.1.5)
4
+ motion-prime (0.1.6)
5
5
  bubble-wrap
6
6
  cocoapods
7
7
  motion-cocoapods
@@ -1,9 +1,12 @@
1
+ motion_require '../helpers/has_normalizer'
1
2
  module MotionPrime
2
3
  class BaseElement
3
4
  # MotionPrime::BaseElement is container for UIView class elements with options.
4
5
  # Elements are located inside Sections
5
6
 
6
7
  include ::MotionSupport::Callbacks
8
+ include HasNormalizer
9
+
7
10
  attr_accessor :options, :section, :name,
8
11
  :view_class, :view, :styles, :screen
9
12
 
@@ -39,7 +42,7 @@ module MotionPrime
39
42
  @computed_options = options
40
43
  compute_block_options
41
44
  compute_style_options
42
- @computed_options = normalize_options(@computed_options)
45
+ @computed_options = normalize_options(@computed_options, section)
43
46
  end
44
47
 
45
48
  # Compute options sent inside block, e.g.
@@ -63,16 +66,6 @@ module MotionPrime
63
66
  Styles.for(styles)
64
67
  end
65
68
 
66
- def normalize_options(options)
67
- options.each do |key, option|
68
- options[key] = if option.is_a?(Proc) && key != :block
69
- section.send :instance_eval, &option
70
- else
71
- option
72
- end
73
- end
74
- end
75
-
76
69
  class << self
77
70
  def factory(type, options = {})
78
71
  class_name = "#{type.classify}Element"
@@ -0,0 +1,14 @@
1
+ module MotionPrime
2
+ module HasNormalizer
3
+ def normalize_options(options, receiver = nil)
4
+ receiver ||= self
5
+ options.each do |key, option|
6
+ options[key] = if option.is_a?(Proc)
7
+ receiver.send :instance_eval, &option
8
+ else
9
+ option
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -157,6 +157,7 @@ module MotionPrime
157
157
  return attributes if self.class.updatable_attributes.blank?
158
158
  self.class.updatable_attributes.to_a.inject({}) do |hash, attribute|
159
159
  key, options = *attribute
160
+ return hash if options[:if] && !send(options[:if])
160
161
  if block = options[:block]
161
162
  value = instance_eval(&block)
162
163
  else
@@ -14,6 +14,7 @@ module MotionPrime
14
14
  DEFAULT_CONTENT_HEIGHT = 65
15
15
  include ::MotionSupport::Callbacks
16
16
  include MotionPrime::HasAuthorization
17
+ include MotionPrime::HasNormalizer
17
18
 
18
19
  attr_accessor :screen, :model, :name, :options, :elements
19
20
  class_attribute :elements_options, :container_options
@@ -77,7 +78,9 @@ module MotionPrime
77
78
  end
78
79
 
79
80
  def container_options
80
- @container_options ||= self.class.container_options.try(:clone) || {}
81
+ @container_options ||= normalize_options(
82
+ self.class.container_options.try(:clone) || {}
83
+ )
81
84
  end
82
85
 
83
86
  def container_height
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -1,3 +1,4 @@
1
+ motion_require '../helpers/has_normalizer'
1
2
  module MotionPrime
2
3
  class Styles
3
4
  @@repo = {}
@@ -17,6 +18,8 @@ module MotionPrime
17
18
  end
18
19
 
19
20
  class << self
21
+ include HasNormalizer
22
+
20
23
  def define(namespace = nil, &block)
21
24
  self.new(namespace).instance_eval(&block)
22
25
  end
@@ -33,12 +36,6 @@ module MotionPrime
33
36
  style_options = self.for(options.delete(:styles))
34
37
  normalize_options(style_options.merge(options))
35
38
  end
36
-
37
- def normalize_options(options)
38
- options.each do |key, option|
39
- options[key] = option.is_a?(Proc) && key != :block ? instance_eval(&option) : option
40
- end
41
- end
42
39
  end
43
40
  end
44
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-prime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
@@ -201,6 +201,7 @@ files:
201
201
  - motion-prime/elements/text_field.rb
202
202
  - motion-prime/elements/text_view.rb
203
203
  - motion-prime/helpers/has_authorization.rb
204
+ - motion-prime/helpers/has_normalizer.rb
204
205
  - motion-prime/helpers/has_search_bar.rb
205
206
  - motion-prime/models/association.rb
206
207
  - motion-prime/models/bag.rb