Skip to content

Releases: octoopi/enumbler

Fix chicken before egg warning with pending migrations

29 Apr 10:58
86145b7
Compare
Choose a tag to compare
0.9.1

Fix chicken before egg error with pending migrations 0.9.1

Check for conflicting method names when enabling a model

14 Dec 12:35
b98bfcd
Compare
Choose a tag to compare
0.8.1

Add error when dynamic method naming conflict exists 0.8.1

Added .find_by_enumble method

26 Oct 18:48
e93aae7
Compare
Choose a tag to compare
Pre-release
0.8.0

Added .find_by_enumble 0.8.0

Allow database column :label to *not* be the enumbler's label

01 Oct 13:02
795a83f
Compare
Choose a tag to compare

This change allows you to have a database column :label that you do not want to use at the Enumble#label.

Added additional attribute helpers for enumbled_to records

06 Jul 16:17
dd12749
Compare
Choose a tag to compare
house = House.create!(color: Color.black)

house.color_label        # => 'black'
house.color_enum         # => :black
house.color_graphql_enum # => 'BLACK'

Adding .find_enumbles class methods

03 Jul 14:35
6fbb3d0
Compare
Choose a tag to compare
Pre-release

Still a work in progress on this concept but wanted a flexible way to extract the label, enum, id, values from an enabled class.

# Get an Enumble object from an id, label, enum, or ActiveRecord model
Color.find_enumbles(:black, 'white') # => [Enumbler::Enumble<:black>, Enumbler::Enumble<:white>]
Color.find_enumbles(:black, 'does-not-exist') # => [Enumbler::Enumble<:black>, nil]

Color.find_enumble(:black) # => Enumbler::Enumble<:black>

# raises errors if none found
Color.find_enumbles!!(:black, 'does-no-exist') # => raises Enumbler::Error
Color.find_enumble!(:does_not_exist) # => raises Enumbler::Error

# Get ids flexibly, without raising an error if none found
Color.ids_from_enumbler(:black, 'white') # => [1, 2]
Color.ids_from_enumbler(:black, 'does-no-exist') # => [1, nil]

# Raise an error if none found
Color.ids_from_enumbler!(:black, 'does-no-exist') # => raises Enumbler::Error
Color.id_from_enumbler!(:does_not_exist) # => raises Enumbler::Error

Added additional singleton magic

26 Jun 13:56
70b1424
Compare
Choose a tag to compare
Pre-release

Added ability to get an attribute of an Enumbled record.

Color.black(:id)           # => 1
Color.black(:enum)         # => :black
Color.black(:label)        # => 'black'
Color.black(:graphql_enum) # => 'BLACK'

Added class method enumber_label_column_name

21 May 14:01
85f6501
Compare
Choose a tag to compare

Used when your database has a column with a name other than label.

Added .id_from_enumbler method

21 May 13:59
Compare
Choose a tag to compare
Pre-release

Added singular version of the .ids_from_enumbler method.

Renamed ids_from_enumablable

21 May 13:59
Compare
Choose a tag to compare
Pre-release

Renamed .ids_from_enumablable to .ids_from_enumbler. Not sure what happened with the first attempt at naming that.