Class: Yoda::Model::Types::ValueType
- Defined in:
- lib/yoda/model/types/value_type.rb
Constant Summary collapse
- VALUE_REGEXP =
/\A[0-9a-z]/
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #change_root(paths) ⇒ self
- #eql?(another) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(value) ⇒ ValueType
constructor
A new instance of ValueType.
- #resolve(registry) ⇒ Array<YARD::CodeObjects::Base>
- #to_s ⇒ String
- #value_class ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(value) ⇒ ValueType
Returns a new instance of ValueType.
10 11 12 |
# File 'lib/yoda/model/types/value_type.rb', line 10 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/yoda/model/types/value_type.rb', line 5 def value @value end |
Instance Method Details
#change_root(paths) ⇒ self
26 27 28 |
# File 'lib/yoda/model/types/value_type.rb', line 26 def change_root(paths) self end |
#eql?(another) ⇒ Boolean
15 16 17 18 |
# File 'lib/yoda/model/types/value_type.rb', line 15 def eql?(another) another.is_a?(ValueType) && value == another.value end |
#hash ⇒ Object
20 21 22 |
# File 'lib/yoda/model/types/value_type.rb', line 20 def hash [self.class.name, value].hash end |
#resolve(registry) ⇒ Array<YARD::CodeObjects::Base>
32 33 34 |
# File 'lib/yoda/model/types/value_type.rb', line 32 def resolve(registry) [Store::Query::FindConstant.new(registry).find(value_class)].compact end |
#to_s ⇒ String
52 53 54 |
# File 'lib/yoda/model/types/value_type.rb', line 52 def to_s value end |
#value_class ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/yoda/model/types/value_type.rb', line 36 def value_class case value when 'true' '::TrueClass' when 'false' '::FalseClass' when 'nil' '::NilClass' when /\A\d+\Z/ '::Numeric' else nil end end |