Class: Appboard::WidgetPusher

Inherits:
Object
  • Object
show all
Defined in:
lib/appboard/widgetpusher.rb

Overview

Widget pusher

Defined Under Namespace

Classes: Widget

Instance Method Summary collapse

Instance Method Details

#apiKey(value = nil) ⇒ Object

Define API key



31
32
33
34
# File 'lib/appboard/widgetpusher.rb', line 31

def apiKey(value = nil)                                                                                                   
  @apiKey = value unless value.nil?                                                                                   
  @apiKey                                                                                     
end

#get_widgetsObject



58
59
60
# File 'lib/appboard/widgetpusher.rb', line 58

def get_widgets
  @widgets
end

#widget(widget_name = nil) ⇒ Object

Define a widget. May be called inside push loop or separately

widget(‘name’)

uid "..."

data do
  # Data is here
end



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/appboard/widgetpusher.rb', line 46

def widget(widget_name = nil)
  if block_given?
    block = Proc.new
    widget = Widget.new(widget_name, &block)
            
    (@widgets ||= []) << widget
    self
  else
    raise ArgumentError, "Widget is not defined, to define new widget you must supply a block as the last argument" if widget.nil?
  end
end