Class: Reflekt::MetaBuilder
- Inherits:
-
Object
- Object
- Reflekt::MetaBuilder
- Defined in:
- lib/meta_builder.rb
Class Method Summary collapse
-
.create(value) ⇒ Object
Create meta type for matching data type.
-
.create_many(values) ⇒ Object
Create meta for multiple values.
- .data_type_to_meta_type(value) ⇒ Object
Class Method Details
.create(value) ⇒ Object
Create meta type for matching data type.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/meta_builder.rb', line 25 def self.create(value) = nil data_type = value.class.to_s case data_type when "Array" = ArrayMeta.new() when "TrueClass", "FalseClass" = BooleanMeta.new() when "Float" = FloatMeta.new() when "Integer" = IntegerMeta.new() when "String" = StringMeta.new() else unless value.nil? = ObjectMeta.new() end end unless .nil? .load(value) end return end |
.create_many(values) ⇒ Object
Create meta for multiple values.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/meta_builder.rb', line 60 def self.create_many(values) = [] values.each do |value| << self.create(value) end return end |
.data_type_to_meta_type(value) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/meta_builder.rb', line 75 def self.(value) data_type = value.class = { Array => :array, TrueClass => :bool, FalseClass => :bool, Float => :float, Integer => :int, NilClass => :null, String => :string } if .key? data_type return [data_type] elsif value.nil? return nil else return :object end end |