classy_enum 4.0.0 → 4.0.1.beta1

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: 78bc9a162cff923b835c2887e1722a4ec240c867
4
- data.tar.gz: 2a618cd93d0e3e01439ff604a87aa6c6f2c0eb80
3
+ metadata.gz: e979d4b03dc2cb8459da434c579f38aca41dfe9f
4
+ data.tar.gz: 88a383a5a3afe04fb35fcc3c41ff5618ca2aca0d
5
5
  SHA512:
6
- metadata.gz: cec7b51f1ebdacb68250cee5fae7b15e5d5bacbe487a4ecf78c065c5b3554b4bdca2651e5b1c87dd26d12361e6502a066749491935964cc657fad3a536323de4
7
- data.tar.gz: 75b78af33ef1a4f4532e3f873e1e6fc1b1349a62bd6249535e8ee5822f6624d1dba5b1874124e9438f5456c294b703372ede1548fd0d2e73dd59a8a709f70761
6
+ metadata.gz: 5d53d1be8df63e19beb763cda458cd4303c1f25e3fa308c402573d51403766b2699239ff5b1abca0f9b00e513958d4bfd3228205324f0e46ba9e3ee6ae72f303
7
+ data.tar.gz: dda8018abaacc1aba9e11673b1efd250979ef0971293cda9b6b615a0af610e8e7045c6ac2bc2cd99ae5e1470b170b3399f59441fd9e37e294ff17a33c15dabb1
@@ -1,5 +1,9 @@
1
1
  # ClassyEnum Changelog
2
2
 
3
+ ## 4.0.1 (Beta)
4
+
5
+ * Adds support for Active Record store accessors (#52)
6
+
3
7
  ## 4.0.0
4
8
 
5
9
  * Adds support for Ruby 2.2.0
data/README.md CHANGED
@@ -19,6 +19,18 @@ This README is also available in a [user-friendly DocumentUp format](http://beer
19
19
 
20
20
  The gem is hosted at [rubygems.org](https://rubygems.org/gems/classy_enum)
21
21
 
22
+ Despite [RailsGuides](http://guides.rubyonrails.org/configuring.html#rails-general-configuration)
23
+ claiming that all directories under app will be autoloaded,
24
+ I've had [reports](https://github.com/beerlington/classy_enum/issues/50)
25
+ of this not being the case with newer versions of Ruby and Rails.
26
+
27
+ You may need to add the enums path to **config/application.rb**:
28
+
29
+ ```ruby
30
+ # Make sure classy_enum enums get loaded
31
+ config.autoload_paths += %W(#{config.root}/app/enums)
32
+ ```
33
+
22
34
  ## Upgrading?
23
35
 
24
36
  See the [wiki](https://github.com/beerlington/classy_enum/wiki/Upgrading) for notes about upgrading from previous versions.
@@ -75,7 +75,7 @@ module ClassyEnum
75
75
 
76
76
  # Define getter method that returns a ClassyEnum instance
77
77
  define_method attribute do
78
- enum.build(read_attribute(attribute), owner: self)
78
+ enum.build(read_attribute(attribute) || super(), owner: self)
79
79
  end
80
80
 
81
81
  # Define setter method that accepts string, symbol, instance or class for member
@@ -109,7 +109,7 @@ module ClassyEnum
109
109
  # database and make it searchable.
110
110
  if default.present?
111
111
  after_initialize do
112
- value = read_attribute(attribute)
112
+ value = read_attribute(attribute) || send(attribute)
113
113
 
114
114
  if (value.blank? && !(allow_blank || allow_nil)) || (value.nil? && !allow_nil)
115
115
  send("#{attribute}=", default)
@@ -1,3 +1,3 @@
1
1
  module ClassyEnum
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1.beta1"
3
3
  end
@@ -9,6 +9,7 @@ ActiveRecord::Schema.define(version: 1) do
9
9
  t.string :color
10
10
  t.string :name
11
11
  t.integer :age
12
+ t.text :properties
12
13
  end
13
14
 
14
15
  create_table :cats, force: true do |t|
@@ -273,6 +274,26 @@ describe Dog, 'with invalid default value' do
273
274
  end
274
275
  end
275
276
 
277
+ class Bark < ClassyEnum::Base; end
278
+ class Bark::Quiet < Bark; end;
279
+ class Bark::Loud < Bark; end;
280
+
281
+ class StoreDog < Dog
282
+ store :properties, accessors: [:bark]
283
+ classy_enum_attr :bark
284
+ end
285
+
286
+ describe StoreDog, rails_3: :broken do
287
+ subject { StoreDog.new(bark: :loud) }
288
+ it { should be_valid }
289
+
290
+ it 'persists the enum in a store accessor' do
291
+ subject.save!
292
+ subject.reload
293
+ subject.bark.should be_a(Bark::Loud)
294
+ end
295
+ end
296
+
276
297
  class Cat < ActiveRecord::Base
277
298
  include ClassyEnum::ActiveRecord
278
299
  end
@@ -11,4 +11,5 @@ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:"
11
11
 
12
12
  RSpec.configure do |config|
13
13
  config.color_enabled = true
14
+ config.filter_run_excluding rails_3: :broken if ActiveRecord::VERSION::MAJOR < 4
14
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classy_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Brown
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-28 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -124,12 +124,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - ">"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: 1.3.1
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.4.5
132
+ rubygems_version: 2.4.6
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: A class based enumerator utility for Ruby on Rails