Class: Chameleon::Widget

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Widget

Returns a new instance of Widget.



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

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

Class Method Details

.find(name) ⇒ Object



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

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



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

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

Instance Method Details

#auth(&block) ⇒ Object



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

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

#data(&block) ⇒ Object



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

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

#key(value = nil) ⇒ Object



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

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

#key_parameter(value = nil) ⇒ Object



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

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

#nameObject



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

def name
  @name
end

#public(value = nil) ⇒ Object



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

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

#type(value = nil) ⇒ Object



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

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