actionset 0.1.2 → 0.1.3

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: 774352b690a93db3fb945efc355fa2b25f4db374
4
- data.tar.gz: 04353287325fb16dbc506bb428e41866a75beb40
3
+ metadata.gz: 2ee586ba731ff0d62c70c6417a6a66e439118ed2
4
+ data.tar.gz: f9db7e51b54c2865171d2b4bf34751565e602616
5
5
  SHA512:
6
- metadata.gz: 7371c62d1e97d68f6057df93c1246514a1cfc0b1ab01293391a1122568852605510a2ed4c6016011c7603d15a587436ed80fcdd7612caffc969dfe7d2fdf4a77
7
- data.tar.gz: eee0d2b0d631796d8f16d93857a9f1cb81cb87c2dfc4f5de20c9ff064265a124485e202029d10fb6900d079d3ece164fe8676752b074a77d7ffe34e8b4c11e4f
6
+ metadata.gz: ca9fc3e8a5446736ecce76e39b5d16bda747f231760fbc25ed644ca55a5c60895844a50cddbca18befe9cbd0c4a190bcb7b7cc93d5d01adaf3767e0b4d9bf530
7
+ data.tar.gz: 545317adeca664239fdbcfb9413d4dcd9a3c7d4b1a08dd0b1ae50a982d75be32a29ebda542ea01f208343ff440797e3caf4c2fbf6e652e3986842cb08df48d35
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v 0.1.3
2
+ - Ensure that the ActiveModelAdapter for the typcastor properly downgrades from using ActiveModel::Type to using ActiveRecord::Type
3
+ - Ensure that OpenStuct is explicly required
4
+ - Ensure that the internal dummy app has the actionpack infrastructure properly in place for view specs
5
+ - Fix the filter view specs
1
6
  v 0.1.2
2
7
  - Properly specify the version dependency on ActiveSupport
3
8
  v 0.1.1
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
  gemspec
9
9
 
10
10
  group :test do
11
+ gem 'actionpack'
11
12
  gem 'activerecord'
12
13
  gem 'rspec-rails'
13
14
  gem 'sqlite3'
data/lib/action_set.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'rails/railtie'
4
4
  require 'active_support/core_ext/object/blank'
5
5
  require 'active_set'
6
+ require 'ostruct'
6
7
 
7
8
  require 'action_set/version'
8
9
  require_relative './action_set/instructions/entry_value'
@@ -55,7 +55,11 @@ module ActionSet
55
55
  end
56
56
 
57
57
  class ActiveModelAdapter
58
- require 'active_model/type'
58
+ begin
59
+ require 'active_model/type'
60
+ rescue LoadError
61
+ require 'active_record/type'
62
+ end
59
63
 
60
64
  def initialize(raw, target)
61
65
  @raw = raw
@@ -74,11 +78,11 @@ module ActionSet
74
78
  end
75
79
 
76
80
  def possible_typecasters
77
- @possible_typecasters ||= ActiveModel::Type.constants
78
- .map(&:to_s)
79
- .select { |t| can_typecast?(t) }
80
- .map { |t| init_typecaster(t) }
81
- .compact
81
+ @possible_typecasters ||= type_class.constants
82
+ .map(&:to_s)
83
+ .select { |t| can_typecast?(t) }
84
+ .map { |t| init_typecaster(t) }
85
+ .compact
82
86
  end
83
87
 
84
88
  def typecast(to_type, value)
@@ -87,16 +91,22 @@ module ActionSet
87
91
  end
88
92
 
89
93
  def can_typecast?(const_name)
90
- typecasting_class = ActiveModel::Type.const_get(const_name)
94
+ typecasting_class = type_class.const_get(const_name)
91
95
  typecasting_class.instance_methods.include?(:cast) ||
92
96
  typecasting_class.instance_methods.include?(:type_cast)
93
97
  end
94
98
 
95
99
  def init_typecaster(const_name)
96
- ActiveModel::Type.const_get(const_name).new
100
+ type_class.const_get(const_name).new
97
101
  rescue
98
102
  nil
99
103
  end
104
+
105
+ def type_class
106
+ ActiveModel::Type
107
+ rescue NameError
108
+ ActiveRecord::Type
109
+ end
100
110
  end
101
111
 
102
112
  class BooleanAdapter
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionSet
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim