class Enumbler::Enumble
Class that holds each row of Enumble
data.
Attributes
enum[R]
id[R]
label[R]
label_column_name[R]
Public Class Methods
new(enum, id, label: nil, label_column_name: :label, **attributes)
click to toggle source
# File lib/enumbler/enumble.rb, line 8 def initialize(enum, id, label: nil, label_column_name: :label, **attributes) @id = id @enum = enum @label_column_name = label_column_name @label = (label_col_specified? ? attributes[label_column_name] : label) || enum.to_s.dasherize @additional_attributes = attributes || {} @additional_attributes.merge!({ label: label }) unless label.nil? end
Public Instance Methods
==(other)
click to toggle source
# File lib/enumbler/enumble.rb, line 17 def ==(other) other.class == self.class && (other.id == id || other.enum == enum || other.label == label) end
attributes()
click to toggle source
# File lib/enumbler/enumble.rb, line 22 def attributes hash = { id: id, label_column_name => label } @additional_attributes.merge(hash) end
enumble()
click to toggle source
Used to return itself from a class method.
“` Color.black(:enumble) #=> <Enumble:0x00007fb4396a78c8> “` @return [Enumbler::Enumble]
# File lib/enumbler/enumble.rb, line 33 def enumble self end
eql?(other)
click to toggle source
# File lib/enumbler/enumble.rb, line 37 def eql?(other) other.class == self.class && (other.id == id || other.enum == enum || other.label == label) end
graphql_enum()
click to toggle source
Standardizing the enum for a GraphQL schema with an uppercase string value. @return [String]
# File lib/enumbler/enumble.rb, line 45 def graphql_enum enum.to_s.upcase end
to_s()
click to toggle source
# File lib/enumbler/enumble.rb, line 49 def to_s enum end
Private Instance Methods
label_col_specified?()
click to toggle source
# File lib/enumbler/enumble.rb, line 55 def label_col_specified? label_column_name != :label end