temping 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/temping.rb +8 -6
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afd1fb78044162184ad12630ccdb32bc7e2327e4
4
- data.tar.gz: e2751e4a8c993cd70be3299dbaad57ee4718bc7c
3
+ metadata.gz: 67ebb74f4b62c45ecd5bd6baec76e1ba73284d83
4
+ data.tar.gz: 5bdfed95158838b3f00017e3d210d316e799c3a2
5
5
  SHA512:
6
- metadata.gz: 1bd265cbc2d5a0f21ae10763d33178016cfab402e2a0d0033223384698e2ab1251ac271f8bfe4b12dbd5b66dcfcbfa3a35111edc9dc3de750005e6dd4b7fd128
7
- data.tar.gz: af8c4e99df32195956faa6d0e2d0d49298eaf9168afc1f9fb3e73a8fb7c2106422e1ca6c41cd18663dc6790afd006dff10185450ed6c5c4cb9b60ddf0998f1bf
6
+ metadata.gz: ff18c2a9e0896645e114370ec94bda2c21cfa8fd4d6d29dd3cacd32bd23447090084a3d3c84fcc6993a33196696bd8631b0bc069c7abfc5ba485cbfff468aac2
7
+ data.tar.gz: 639ded7dd61bad695d7a69291176feb36439967a11624c18d6234c9ed68bdf659c4571d520e772ab5cc8770192e89f8f78807b98d936ef038e9c708a94df1911
data/lib/temping.rb CHANGED
@@ -4,8 +4,8 @@ require "active_support/core_ext/string"
4
4
  class Temping
5
5
  @model_klasses = []
6
6
 
7
- def self.create(model_name, &block)
8
- factory = ModelFactory.new(model_name.to_s.classify, &block)
7
+ def self.create(model_name, options = {}, &block)
8
+ factory = ModelFactory.new(model_name.to_s.classify, options, &block)
9
9
  klass = factory.klass
10
10
  @model_klasses << klass
11
11
  klass
@@ -22,8 +22,9 @@ class Temping
22
22
  end
23
23
 
24
24
  class ModelFactory
25
- def initialize(model_name, &block)
25
+ def initialize(model_name, options = {}, &block)
26
26
  @model_name = model_name
27
+ @options = options
27
28
  klass.class_eval(&block) if block_given?
28
29
  klass.reset_column_information
29
30
  end
@@ -41,13 +42,14 @@ class Temping
41
42
  Object.const_set(@model_name, klass)
42
43
 
43
44
  klass.primary_key = :id
44
- create_table
45
+ create_table(@options)
45
46
  add_methods
46
47
  end
47
48
  end
48
49
 
49
- def create_table
50
- connection.create_table(table_name, :temporary => true)
50
+ DEFAULT_OPTIONS = { :temporary => true }
51
+ def create_table(options = {})
52
+ connection.create_table(table_name, DEFAULT_OPTIONS.merge(options))
51
53
  end
52
54
 
53
55
  def add_methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temping
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Pignata
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 2.13.0
103
+ version: 3.4.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 2.13.0
110
+ version: 3.4.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.5.1
151
+ rubygems_version: 2.6.2
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Create temporary table-backed ActiveRecord models for use in tests