Class: Glib::JsonUi::JsonUiElement

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/glib/json_ui/abstract_builder.rb

Constant Summary collapse

@@_required_properties =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, page) ⇒ JsonUiElement

Returns a new instance of JsonUiElement.



53
54
55
56
# File 'app/helpers/glib/json_ui/abstract_builder.rb', line 53

def initialize(json, page)
  @json = json
  @page = page
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



49
50
51
# File 'app/helpers/glib/json_ui/abstract_builder.rb', line 49

def json
  @json
end

#pageObject (readonly)

Returns the value of attribute page.



49
50
51
# File 'app/helpers/glib/json_ui/abstract_builder.rb', line 49

def page
  @page
end

Instance Method Details

#props(args = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/helpers/glib/json_ui/abstract_builder.rb', line 58

def props(args = {})
  @args = args

  if args.is_a? Hash
    args.each do |k, v|
      send(k, v)
    end

    required_properties = @@_required_properties[self.class.component_name] || []
    required_properties.each do |prop|
      raise "Property required: #{prop}. Properties provided: #{args}. Component: #{self.class.component_name}" unless args[prop].present?
    end
  else
    raise "Invalid properties: #{args}"
  end

  created
end