Class: SmartEnum::Attributes::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_enum/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, types, coercer) ⇒ Attribute

Returns a new instance of Attribute.



132
133
134
135
136
# File 'lib/smart_enum/attributes.rb', line 132

def initialize(name, types, coercer)
  @name = name
  @types = types
  @coercer = coercer
end

Instance Attribute Details

#coercerObject (readonly)

Returns the value of attribute coercer.



130
131
132
# File 'lib/smart_enum/attributes.rb', line 130

def coercer
  @coercer
end

#nameObject (readonly)

Returns the value of attribute name.



130
131
132
# File 'lib/smart_enum/attributes.rb', line 130

def name
  @name
end

#typesObject (readonly)

Returns the value of attribute types.



130
131
132
# File 'lib/smart_enum/attributes.rb', line 130

def types
  @types
end

Instance Method Details

#inspectObject



138
139
140
141
# File 'lib/smart_enum/attributes.rb', line 138

def inspect
  type_str = types.length > 1 ? types.join("|") : types[0]
  "#{name}: #{type_str}"
end