bank 0.1.10 → 0.1.11

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: fac711d36badd553b5811cbd2536260a02bdfbc1
4
- data.tar.gz: c68dae266a677d0852a1b6d8689e7a81f39dabca
3
+ metadata.gz: 18889ba4a4570b3506bd3373d0238031eba17f12
4
+ data.tar.gz: e34ffc1f90e7cbbc0eb5a8dfb572ba50fec2a192
5
5
  SHA512:
6
- metadata.gz: ab112b825a7a9a63e1fac2ddd0a7b31d11deba91be0a11a43edd01239a3cb3ebea81197128b403b63281169a8c99d9c23d57f96e1b36f8888173b72864575818
7
- data.tar.gz: 9b08546a176b01ef5f39341ef2cb376768aa9a351359e384ce2d52f76e11b2129f0b17164c09e257127aaf7c262274e02383975cfd8adabb5e297e15acba60a0
6
+ metadata.gz: 1d7ef7ddefd179639b2c056a588d243115f81632dfb16227159033aefcdb6df63fa3fc20272c9d3bb97f196c7fac1149a2e2c6f71f1e2304658701582a273785
7
+ data.tar.gz: e71b17e2d88ca8d6b2c6e47dd5a2f5c850bede3479d7d8f1bca13508bc271b5263d38866df507d6cb8b39e1e454e0d384abffe66a001c98368ef9fb9837978a0
@@ -26,6 +26,10 @@ module Bank
26
26
  Result.new(config.db, self)
27
27
  end
28
28
 
29
+ def scope(name, blk)
30
+ define_singleton_method(name) { |*args| instance_exec *args, &blk }
31
+ end
32
+
29
33
  def find_by(key, value)
30
34
  where(key => value).first
31
35
  end
@@ -80,12 +84,10 @@ module Bank
80
84
  end
81
85
 
82
86
  def join_select(table, *args, &blk)
83
- select(*config.model._fields.map { |f| :"#{table}__#{f}"}).
87
+ select(*config.model.config._fields.map { |f| :"#{table}__#{f}"}).
84
88
  join(*args, &blk)
85
89
  end
86
90
 
87
- private
88
-
89
91
  def new?(model)
90
92
  model.send(config.primary_key).nil?
91
93
  end
@@ -1,4 +1,5 @@
1
1
  require 'attr_protected'
2
+ require 'bank'
2
3
 
3
4
  module Bank
4
5
  class CollectionConfig
data/lib/bank/model.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'attr_protected'
2
2
 
3
3
  module Bank
4
- class Model
4
+ module Model
5
5
  class Config
6
6
  attr_protected :_fields, :_defaults, :_model
7
7
 
@@ -37,6 +37,8 @@ module Bank
37
37
  config.columns_of_type(:datetime).each { |column, opts|
38
38
  time = attrs[column]
39
39
  attrs[column] = case time
40
+ when NilClass
41
+ nil
40
42
  when String
41
43
  Time.at(Time.parse(time).to_i)
42
44
  when DateTime
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Pratt