Class: AdvAccessor::Base

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/adv_accessor/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/adv_accessor/base.rb', line 4

def method
  @method
end

#null_valueObject

Returns the value of attribute null_value.



5
6
7
# File 'lib/adv_accessor/base.rb', line 5

def null_value
  @null_value
end

#readerObject

Returns the value of attribute reader.



6
7
8
# File 'lib/adv_accessor/base.rb', line 6

def reader
  @reader
end

Instance Method Details

#basic_valueObject



15
16
17
18
19
# File 'lib/adv_accessor/base.rb', line 15

def basic_value
  res = raw_value
  res = reader[res] if reader
  res
end

#raw_valueObject



10
11
12
13
14
# File 'lib/adv_accessor/base.rb', line 10

def raw_value
  return @value if @value
  @value = null_value[] if null_value
  @value
end

#value(type = nil) ⇒ Object



20
21
22
23
# File 'lib/adv_accessor/base.rb', line 20

def value(type=nil)
  return basic_value unless type
  readers.get(type)
end

#value=(x) ⇒ Object



7
8
9
# File 'lib/adv_accessor/base.rb', line 7

def value=(x)
  @input_value = @value = x
end