Class: UU::OS::VUC::View

Inherits:
GVC::Container show all
Defined in:
uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb

Overview

View object used for communication with forms.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from GVC::Container

#add_message, #components, #focus, #focused_component, #get_component_by_id, #get_components_by_code, #messages

Constructor Details

- (View) initialize(data = nil)

Creates new instance of view.

Parameters:

  • data (String, Hash) (defaults to: nil)

    Initialization data in form of JSON string or Hash (optional)



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 52

def initialize(data = nil)
  super(data)
  if data.nil?
    return
  end
  if data.kind_of?String
    data = JSON.parse(data, :symbolize_names => true)
  end
  if !data.kind_of?Hash
    raise ArgumentError.new("View data must be JSON String or Hash, but was #{data.class}.")
  end
  @id = data[:id]
  @code = data[:code]
  @name = data[:name]
  @status = data[:status]
  @component_type = data[:component_type]
  @event = UU::OS::VUC::Event.new(data[:event])
  @context = UU::OS::VUC::Context.new(data[:context])
  @navigation = UU::OS::VUC::Navigation.new(data[:navigation])
end

Instance Attribute Details

- (String) code (readonly)

View code.

Returns:

  • (String)


22
23
24
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 22

def code
  @code
end

- (Numeric) component_type (readonly)

View type.

Returns:

  • (Numeric)


35
36
37
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 35

def component_type
  @component_type
end

- (UU::OS::VUC::Context) context (readonly)

Use case context.



43
44
45
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 43

def context
  @context
end

- (UU::OS::VUC::Event) event (readonly)

Incoming event.

Returns:



39
40
41
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 39

def event
  @event
end

- (String) id (readonly)

Unique view ID.

Returns:

  • (String)


18
19
20
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 18

def id
  @id
end

- (String) name (readonly)

View name.

Returns:

  • (String)


26
27
28
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 26

def name
  @name
end

What should form do next.



47
48
49
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 47

def navigation
  @navigation
end

- (Numeric) status

HTTP status code of processed request (possible values are available on HTTPStatus).

Parameters:

  • (Numeric)

Returns:

  • (Numeric)


31
32
33
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 31

def status
  @status
end

Instance Method Details

- (String) to_response

Serializes view to JSON.

Returns:

  • (String)

    Serialized view



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'uu_adk_client-0.9.6/lib/uu/os/vuc/view.rb', line 76

def to_response
  response = {}
  response[:id] = @id
  response[:code] = @code
  response[:name] = @name
  response[:status] = @status
  response[:componentType] = @component_type
  response[:event] = @event.raw_attrs if (@event.raw_attrs) && (!@event.raw_attrs.empty?)
  response[:context] = @context.raw_attrs if (@context.raw_attrs) && (!@context.raw_attrs.empty?)
  if (@components) && (@components.values.size > 0)
    response[:components] = []
    @components.values.each do |component|
      response[:components] << component.attributes
    end
  end
  if (@messages) && (@messages.size > 0)
    response[:messages] = []
    @messages.each do |message|
      response[:messages] << message.raw_attrs
    end
  end
  response[:navigation] = @navigation.raw_attrs if (@navigation.raw_attrs) && (!@navigation.raw_attrs.empty?)
  response[:focusOn] = @focus_on if @focus_on
  response.to_json
end