organizze-form 0.0.2 → 0.0.3

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/organizze-form/row.rb +35 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 430bb1c85999b6cf744655697d01221be9c80120
4
- data.tar.gz: e4118992bb155cfbd3393a397b3eef1ec1654596
3
+ metadata.gz: 7d4d3fe00dc9769dc32c4e7488e30e893207239b
4
+ data.tar.gz: a328b0cfb7e831c0b191f16aa7ad0c2ec9acb7f5
5
5
  SHA512:
6
- metadata.gz: 53940347991c23f68aa08cfe52478be51402c9d4863439e16817324a15480aff2739a2840b4d42932a65fe758a4eb114f490b8f7c72915561285dde6f0eaa9e2
7
- data.tar.gz: b206c4f04350158b855ac64b469376cd33124224135492b8a06c8705833591f94150dab5ab3a7c529e9d0d1c4b68b771af2bd579723125cbc97dc31222b25abb
6
+ metadata.gz: 94f7a0cf33138166d2dd08f518399f28d9c62e0568937455804f84f55e3819080cf4de8b7c8f51105a39bb763d7c5d4daf64a52b4e9d5b9b024473958eab4838
7
+ data.tar.gz: b689854eccc13a9899cfeb3d65e17c2732af9947ce4fcd098cd6bc3b88694a241930cdaaed644796aed86628f5f2a2eaa0cafd4998b626b644da48b4c3b4483f
@@ -3,7 +3,7 @@ module OrganizzeForm
3
3
  attr_accessor :type, :key, :value
4
4
 
5
5
  def row_type
6
- @row_type ||= row_type_class.new.tap do |rt|
6
+ @row_type ||= row_type_class.new.tap do |rt|
7
7
  rt.row = WeakRef.new(self)
8
8
  end
9
9
  end
@@ -12,17 +12,45 @@ module OrganizzeForm
12
12
  row_type.setup_call
13
13
  end
14
14
 
15
- def row_type_class
16
- "RowTypes::#{camelize(self.type)}".to_klass
15
+ private
16
+
17
+ def row_type_class
18
+ constantize("OrganizzeForm::RowTypes::#{camelize(self.type)}")
17
19
  end
18
20
 
19
21
  def camelize(term)
20
- parts = term.strip('_')
21
- str = ''
22
+ parts = term.split('_')
23
+ camel_cased_word = ''
22
24
  for p in parts
23
- str << p.capitalize
25
+ camel_cased_word << p.capitalize
26
+ end
27
+ camel_cased_word
28
+ end
29
+
30
+ def constantize(camel_cased_word)
31
+ names = camel_cased_word.split('::')
32
+ names.shift if names.empty? || names.first.empty?
33
+
34
+ names.inject(Object) do |constant, name|
35
+ if constant == Object
36
+ constant.const_get(name)
37
+ else
38
+ candidate = constant.const_get(name)
39
+ next candidate if constant.const_defined?(name, false)
40
+ next candidate unless Object.const_defined?(name)
41
+
42
+ # Go down the ancestors to check it it's owned
43
+ # directly before we reach Object or the end of ancestors.
44
+ constant = constant.ancestors.inject do |const, ancestor|
45
+ break const if ancestor == Object
46
+ break ancestor if ancestor.const_defined?(name, false)
47
+ const
48
+ end
49
+
50
+ # owner is in Object, so raise
51
+ constant.const_get(name, false)
52
+ end
24
53
  end
25
- str
26
54
  end
27
55
  end
28
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: organizze-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Felipe Colle da Luz
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Simple rubymotion form helper for uiTableViews
27
+ description: Simple rubymotion form helper for UITableViews
28
28
  email:
29
29
  - solanoluz@gmail.com
30
30
  executables: []