Class: AttrTypecastable::Reflection

Inherits:
Object
  • Object
show all
Defined in:
lib/attr_typecastable/reflection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute_name, typecaster, **options) ⇒ Reflection

Returns a new instance of Reflection.



5
6
7
8
9
10
# File 'lib/attr_typecastable/reflection.rb', line 5

def initialize(attribute_name, typecaster, **options)
  @attribute_name = attribute_name
  @typecaster = typecaster
  @options = options
  freeze
end

Instance Attribute Details

#attribute_nameObject (readonly)

Returns the value of attribute attribute_name.



3
4
5
# File 'lib/attr_typecastable/reflection.rb', line 3

def attribute_name
  @attribute_name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/attr_typecastable/reflection.rb', line 3

def options
  @options
end

#typecasterObject (readonly)

Returns the value of attribute typecaster.



3
4
5
# File 'lib/attr_typecastable/reflection.rb', line 3

def typecaster
  @typecaster
end

Instance Method Details

#defaultObject



12
13
14
# File 'lib/attr_typecastable/reflection.rb', line 12

def default
  @options[:default]
end

#has_default?Boolean

Returns:



16
17
18
# File 'lib/attr_typecastable/reflection.rb', line 16

def has_default?
  @options.key?(:default)
end