Class: Diva::Type::MetaType

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

Overview

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

Direct Known Subclasses

ArrayType, AtomicType, ModelType, UnionType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &cast) ⇒ MetaType

Returns a new instance of MetaType.



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

def initialize(name, *, &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.



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

def name
  @name
end

Instance Method Details

#cast(value) ⇒ Object



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

def cast(value)
  value
end

#dump_for_json(value) ⇒ Object



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

def dump_for_json(value)
  value
end

#inspectObject



75
76
77
# File 'lib/diva/type.rb', line 75

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

#to_sObject



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

def to_s
  name.to_s
end