Class: Widget

Inherits:
Object
  • Object
show all
Defined in:
app/models/widget.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Widget

Returns a new instance of Widget.



14
15
16
17
# File 'app/models/widget.rb', line 14

def initialize(name, &block)
  @name = name
  instance_eval(&block)
end

Class Method Details

.find(name) ⇒ Object



9
10
11
12
# File 'app/models/widget.rb', line 9

def self.find(name)
  Dir.glob(File.join("app", "widgets", "*.rb")).each { |f| load File.expand_path(f) } if Rails.env == "development"
  (@@widgets || {})[name.to_sym]
end

.widget(name, &block) ⇒ Object



4
5
6
7
# File 'app/models/widget.rb', line 4

def self.widget(name, &block) 
  @@widgets ||= {}
  @@widgets[name] = Widget.new(name, &block)
end

Instance Method Details

#auth(&block) ⇒ Object



33
34
35
36
# File 'app/models/widget.rb', line 33

def auth(&block)
  @auth = block if block_given?
  @auth
end

#data(&block) ⇒ Object



48
49
50
51
# File 'app/models/widget.rb', line 48

def data(&block)
  @data = block if block_given?
  @data
end

#key(value = nil) ⇒ Object



23
24
25
26
# File 'app/models/widget.rb', line 23

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

#key_parameter(value = nil) ⇒ Object



28
29
30
31
# File 'app/models/widget.rb', line 28

def key_parameter(value = nil)
  @key_parameter = value unless value.nil?
  @key_parameter || :key
end

#nameObject



19
20
21
# File 'app/models/widget.rb', line 19

def name
  @name
end

#public(value = nil) ⇒ Object



43
44
45
46
# File 'app/models/widget.rb', line 43

def public(value = nil)
  @public = value unless value.nil?
  @public || false
end

#type(value = nil) ⇒ Object



38
39
40
41
# File 'app/models/widget.rb', line 38

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