hobo_fields 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd86ea58f333b2b604f564c34fbd1fa881de752a
4
- data.tar.gz: 362708497d9bb86e9180d2aa54fcf54cfd1b1bab
3
+ metadata.gz: ae374e5d1218a6f0810c9f92c324ada484d6b6f7
4
+ data.tar.gz: d115ea2e44e137f51a47a20af4e0931c22460242
5
5
  SHA512:
6
- metadata.gz: 4902e3628e1c82294c3c5039cc66b686d5f9e993509dbb624808a311e7a9e80e58a183509ef5e74b883bce26cde777730a7c9b235f9c3061937109996d1b0cf4
7
- data.tar.gz: befa22f838ac4ece879a18b2693d5e56fde46d18b8e70b29fbd2b281692bedd0ffc00fc6c85648c03d34678cb7d0a27990b4c9612f41a1e3eeaebba1dbde6bd0
6
+ metadata.gz: ff3940da7cc52302e0b195453b86c641a9b57f2a6c8dc5e713fa2eed6ec804c7b8dbb4fa17e2fa8b231722df150d72bcaaf6aa62e75cecc5d70fc7ee4b2c61e7
7
+ data.tar.gz: 9e79e3f50365f9ff2ae05680dbabffda08b354847a14f6fce1b83403c1f38deaad3cf8c31d961ce185c301289e21efe93f69103f4ec1998abb5e5746d7ded979
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'active_record'
3
+ require 'action_view'
3
4
  require 'tmpdir'
4
5
 
5
6
  include Rake::DSL
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.2
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.description = 'Rich field types and migration generator for Rails'
13
13
 
14
14
  s.add_runtime_dependency('hobo_support', ["= #{version}"])
15
- s.add_development_dependency('rubydoctest', [">= 0"])
15
+ # s.add_development_dependency('rubydoctest', [">= 0"])
16
16
  s.add_development_dependency('RedCloth', [">= 0"]) # for testing rich types
17
17
  s.add_development_dependency('kramdown', [">= 0"]) # for testing rich types
18
18
 
@@ -19,11 +19,17 @@ ActiveRecord::Base.class_eval do
19
19
  class << self
20
20
 
21
21
  def can_wrap_with_hobo_type?(attr_name)
22
- if connected?
23
- type_wrapper = try.attr_type(attr_name)
24
- type_wrapper.is_a?(Class) && type_wrapper.not_in?(HoboFields::PLAIN_TYPES.values)
22
+ @can_wrap_cache ||= {}
23
+ if @can_wrap_cache.include?(attr_name)
24
+ @can_wrap_cache[attr_name]
25
25
  else
26
- false
26
+ @can_wrap_cache[attr_name] = \
27
+ if connected?
28
+ type_wrapper = try.attr_type(attr_name)
29
+ type_wrapper.is_a?(Class) && type_wrapper.not_in?(HoboFields::PLAIN_TYPES.values)
30
+ else
31
+ false
32
+ end
27
33
  end
28
34
  end
29
35
 
@@ -82,14 +82,22 @@ module HoboFields
82
82
 
83
83
 
84
84
  # Extend belongs_to so that it creates a FieldSpec for the foreign key
85
- def self.belongs_to_with_field_declarations(name, options={}, &block)
85
+ def self.belongs_to_with_field_declarations(name, *args, &block)
86
+ if args.size == 0 || (args.size == 1 && args[0].kind_of?(Proc))
87
+ options = {}
88
+ args.push(options)
89
+ elsif args.size == 1
90
+ options = args[0]
91
+ else
92
+ options = args[1]
93
+ end
86
94
  column_options = {}
87
95
  column_options[:null] = options.delete(:null) if options.has_key?(:null)
88
96
  column_options[:comment] = options.delete(:comment) if options.has_key?(:comment)
89
97
 
90
98
  index_options = {}
91
99
  index_options[:name] = options.delete(:index) if options.has_key?(:index)
92
- bt = belongs_to_without_field_declarations(name, options, &block)
100
+ bt = belongs_to_without_field_declarations(name, *args, &block)
93
101
  refl = reflections[name.to_sym]
94
102
  fkey = refl.foreign_key
95
103
  declare_field(fkey.to_sym, :integer, column_options)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Locke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hobo_support
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.1
19
+ version: 2.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.1
27
- - !ruby/object:Gem::Dependency
28
- name: rubydoctest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: 2.1.2
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: RedCloth
43
29
  requirement: !ruby/object:Gem::Requirement