Class: CastingAttributes::TypeCaster::Base
- Inherits:
-
Object
- Object
- CastingAttributes::TypeCaster::Base
show all
- Defined in:
- lib/casting_attributes/type_caster/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(model, attr) ⇒ Base
Returns a new instance of Base.
7
8
9
10
|
# File 'lib/casting_attributes/type_caster/base.rb', line 7
def initialize(model, attr)
@model = model
@attribute = attr
end
|
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
5
6
7
|
# File 'lib/casting_attributes/type_caster/base.rb', line 5
def attribute
@attribute
end
|
#model ⇒ Object
Returns the value of attribute model.
5
6
7
|
# File 'lib/casting_attributes/type_caster/base.rb', line 5
def model
@model
end
|
Instance Method Details
#readers ⇒ Object
16
17
18
|
# File 'lib/casting_attributes/type_caster/base.rb', line 16
def readers
[attribute]
end
|
#storage_var ⇒ Object
12
13
14
|
# File 'lib/casting_attributes/type_caster/base.rb', line 12
def storage_var
:"@#{attribute}"
end
|
#typecast(value) ⇒ Object
24
25
26
|
# File 'lib/casting_attributes/type_caster/base.rb', line 24
def typecast(value)
raise NotImplementedError.new
end
|
#writers ⇒ Object
20
21
22
|
# File 'lib/casting_attributes/type_caster/base.rb', line 20
def writers
[:"#{attribute}="]
end
|