Class: Koine::Attributes::Adapter::Base
- Inherits:
-
Object
- Object
- Koine::Attributes::Adapter::Base
show all
- Defined in:
- lib/koine/attributes/adapter/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
7
8
9
|
# File 'lib/koine/attributes/adapter/base.rb', line 7
def initialize
@attribute_name = 'annonymous_attribute_name'
end
|
Instance Attribute Details
#attribute_name ⇒ Object
Returns the value of attribute attribute_name.
5
6
7
|
# File 'lib/koine/attributes/adapter/base.rb', line 5
def attribute_name
@attribute_name
end
|
Instance Method Details
#coerce(value) ⇒ Object
11
12
13
14
15
|
# File 'lib/koine/attributes/adapter/base.rb', line 11
def coerce(value)
return coerce_nil if value.nil?
coerce_not_nil(value)
end
|
#default_value ⇒ Object
17
18
19
20
21
|
# File 'lib/koine/attributes/adapter/base.rb', line 17
def default_value
@default_value.respond_to?(:call) &&
@default_value.call ||
@default_value
end
|
#with_default_value(value = nil, &block) ⇒ Object
30
31
32
33
34
|
# File 'lib/koine/attributes/adapter/base.rb', line 30
def with_default_value(value = nil, &block)
@default_value = value
@default_value = block if block
self
end
|
#with_nil_value(value = nil, &block) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/koine/attributes/adapter/base.rb', line 23
def with_nil_value(value = nil, &block)
@nil_value_set = true
@nil_value = value
@nil_value = block if block
self
end
|