Class: Hahamut::Attribute::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hahamut/attribute/base.rb

Overview

Base value

Direct Known Subclasses

Integer, Json, String, Timestamp

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Base

Returns a new instance of Base.



9
10
11
# File 'lib/hahamut/attribute/base.rb', line 9

def initialize(value)
  @before_cast = value
end

Instance Attribute Details

#before_castObject (readonly)

Returns the value of attribute before_cast.



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

def before_cast
  @before_cast
end

Instance Method Details

#as_jsonObject



17
18
19
# File 'lib/hahamut/attribute/base.rb', line 17

def as_json
  value
end

#to_json(_obj = nil) ⇒ Object



21
22
23
# File 'lib/hahamut/attribute/base.rb', line 21

def to_json(_obj = nil)
  as_json.to_json
end

#valueObject



13
14
15
# File 'lib/hahamut/attribute/base.rb', line 13

def value
  @value ||= before_cast
end