Class: Diva::Type::MetaType

Inherits:
Object
  • Object
show all
Defined in:
lib/diva/type.rb

Overview

全てのType共通のスーパークラス

Direct Known Subclasses

ArrayType, AtomicType, ModelType, OptionalType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *rest, &cast) ⇒ MetaType

Returns a new instance of MetaType.



51
52
53
54
55
56
# File 'lib/diva/type.rb', line 51

def initialize(name, *rest, &cast)
  @name = name.to_sym
  if cast
    define_singleton_method :cast, &cast
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/diva/type.rb', line 49

def name
  @name
end

Instance Method Details

#cast(value) ⇒ Object



58
59
60
# File 'lib/diva/type.rb', line 58

def cast(value)
  value
end

#dump_for_json(value) ⇒ Object



66
67
68
# File 'lib/diva/type.rb', line 66

def dump_for_json(value)
  value
end

#inspectObject



70
71
72
# File 'lib/diva/type.rb', line 70

def inspect
  "Diva::Type(#{to_s})"
end

#to_sObject



62
63
64
# File 'lib/diva/type.rb', line 62

def to_s
  name.to_s
end