Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
292 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'i18n' | ||
|
||
module ClassyEnum | ||
module Translation | ||
|
||
# Returns a translated string of the enum type. Used internally to create | ||
# the select_options array. | ||
# | ||
# Translation location is: | ||
# locale.classy_enum.base_class.enum_string | ||
# | ||
# ==== Example | ||
# # Create an Enum with some elements | ||
# class Priority < ClassyEnum::Base | ||
# end | ||
# | ||
# class Priority::Low < Priority; end | ||
# class Priority::ReallyHigh < Priority; end | ||
# | ||
# # Default translations are `to_s.titlieze` | ||
# Priority::Low.new.text # => 'Low' | ||
# Priority::ReallyHigh.new.text # => 'Really High' | ||
# | ||
# # Assuming we have a translation defined for: | ||
# # es.classy_enum.priority.low # => 'Bajo' | ||
# | ||
# Priority::Low.new.text # => 'Bajo' | ||
def text | ||
I18n.translate to_s, :scope => i18n_scope, :default => to_s.titleize | ||
end | ||
|
||
private | ||
|
||
def i18n_scope | ||
[:classy_enum, base_class.name.underscore] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ClassyEnum | ||
VERSION = "3.0.1" | ||
VERSION = "3.1.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.