raw_column 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31bc310f6cb5fb393f8184a4d57832ab4d3ecb6c
4
- data.tar.gz: d273d7ed0720dbb70de7cf08e5a9ba3fa008af54
3
+ metadata.gz: d9d8db6b41c727a5c50f518652950c08b288099a
4
+ data.tar.gz: d414574955de138c130dd16e4c4e59ffc4332240
5
5
  SHA512:
6
- metadata.gz: f05780ad848ae1f9deb18de04a309bba2da6c7ae225c60dced9bb26292dac7fdd84c9774ab3612cc7ac53322e24d8075bc979e35561325b40ffe9aabaffd09b0
7
- data.tar.gz: fcd394ee18c9f62590ea57cba1b1e3b44e52353a7c0a2ca7ecdeb303e0f11a7a2b063c833210663bcd2c7c831e8cb679d06617eb377d347916a8a0dc4f5bdac0
6
+ metadata.gz: fcdec41913e1c0b7d2971257be40c229e2c63be1598d5858b59a6a3c159dd379122bb8307f3ac04fac896fd43f31f21ca0e560ccb658322cff8ff19362d81a75
7
+ data.tar.gz: 5fe00480f826961c3769022ed47f849e0ac04b97c103b5004059f2968c7f100fbf335c0b360d13f2ffdd03ecc1f5c2526e94ad8c5d97f280e43c5bf4e82eac34
data/lib/raw_column.rb CHANGED
@@ -9,7 +9,7 @@ module RawColumn
9
9
 
10
10
  def raw_column(*column_names)
11
11
  class_eval do
12
- column_names = [:content] if column_names.nil?
12
+ column_names = [:content] if column_names.blank?
13
13
  column_names.each do |column_name|
14
14
  define_method :"raw_#{column_name}" do
15
15
  JsonProxy.new(self, column_name)
@@ -1,9 +1,15 @@
1
1
  module RawColumn
2
2
 
3
+ class TypeCastError < StandardError; end
4
+
3
5
  class JsonProxy
4
6
 
5
7
  def initialize(record, column_name)
6
- @raw_content = record.send(:"#{column_name}_before_type_cast")
8
+ method = :"#{column_name}_before_type_cast"
9
+ unless record.respond_to?(method)
10
+ raise BeforeTypeCastError.new("your column must respond to #{method}")
11
+ end
12
+ @raw_content = record.send(method)
7
13
  end
8
14
 
9
15
  def as_json(*args)
@@ -1,3 +1,3 @@
1
1
  module RawColumn
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raw_column
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
  - Tony Schneider