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.



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

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.



47
48
49
# File 'lib/diva/type.rb', line 47

def name
  @name
end

Instance Method Details

#cast(value) ⇒ Object



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

def cast(value)
  value
end

#inspectObject



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

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

#to_sObject



60
61
62
# File 'lib/diva/type.rb', line 60

def to_s
  name.to_s
end