Class: ActiveMocker::Field

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, options) ⇒ Field

Returns a new instance of Field.



7
8
9
10
11
12
# File 'lib/active_mocker/field.rb', line 7

def initialize(name, type, options)
  @name    = name
  @type    = type
  @primary_key
  @options = options.first || {}
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/active_mocker/field.rb', line 5

def name
  @name
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/active_mocker/field.rb', line 5

def options
  @options
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/active_mocker/field.rb', line 5

def type
  @type
end

Instance Method Details

#defaultObject



24
25
26
# File 'lib/active_mocker/field.rb', line 24

def default
  options[:default]
end

#precisionObject



28
29
30
# File 'lib/active_mocker/field.rb', line 28

def precision
  options[:precision]
end

#primary_keyObject



14
15
16
# File 'lib/active_mocker/field.rb', line 14

def primary_key
  @primary_key
end

#scaleObject



32
33
34
# File 'lib/active_mocker/field.rb', line 32

def scale
  options[:scale]
end

#to_hObject Also known as: to_hash



18
19
20
# File 'lib/active_mocker/field.rb', line 18

def to_h
  {name: name, type: type, options: options}
end