Class: Morpho::Grape::DataWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/morpho/grape/data_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, wrapper_name: nil, key: :data, is_array: false) ⇒ DataWrapper

Returns a new instance of DataWrapper.



9
10
11
12
13
14
# File 'lib/morpho/grape/data_wrapper.rb', line 9

def initialize(model, wrapper_name: nil, key: :data, is_array: false)
  @model = model
  @wrapper_name = wrapper_name
  @key = key
  @is_array = is_array
end

Instance Attribute Details

#is_arrayObject (readonly)

Returns the value of attribute is_array.



6
7
8
# File 'lib/morpho/grape/data_wrapper.rb', line 6

def is_array
  @is_array
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/morpho/grape/data_wrapper.rb', line 5

def key
  @key
end

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/morpho/grape/data_wrapper.rb', line 4

def model
  @model
end

#wrapper_nameObject (readonly)

Returns the value of attribute wrapper_name.



7
8
9
# File 'lib/morpho/grape/data_wrapper.rb', line 7

def wrapper_name
  @wrapper_name
end

Instance Method Details

#ancestorsObject



16
17
18
# File 'lib/morpho/grape/data_wrapper.rb', line 16

def ancestors
  [DataWrapper]
end

#to_sObject



20
21
22
# File 'lib/morpho/grape/data_wrapper.rb', line 20

def to_s
  wrapper_name ? wrapper_name : "data_wrapper_#{object_id}"
end