Class: Uorm::Attributes::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/uorm/attributes/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ Field

Returns a new instance of Field.



6
7
8
9
# File 'lib/uorm/attributes/field.rb', line 6

def initialize name, type
  @name = name.to_sym
  @type = parse_type type
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/uorm/attributes/field.rb', line 4

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/uorm/attributes/field.rb', line 4

def type
  @type
end

Instance Method Details

#as_json(value) ⇒ Object



15
16
17
# File 'lib/uorm/attributes/field.rb', line 15

def as_json value
  type.as_json value if value
end

#convert(value) ⇒ Object



11
12
13
# File 'lib/uorm/attributes/field.rb', line 11

def convert value
  type.convert value if value
end