Class: Bureaucrat::Widgets::Widget
- Inherits:
-
Object
- Object
- Bureaucrat::Widgets::Widget
show all
- Includes:
- Utils
- Defined in:
- lib/bureaucrat/widgets.rb
Overview
Constant Summary
Constants included
from Utils
Utils::ESCAPES
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#blank_value?, #conditional_escape, #escape, #flatatt, #format_string, #make_bool, #make_float, #mark_safe, #pretty_name
Constructor Details
#initialize(attrs = nil) ⇒ Widget
Returns a new instance of Widget.
12
13
14
|
# File 'lib/bureaucrat/widgets.rb', line 12
def initialize(attrs = nil)
@attrs = attrs.nil? ? {} : attrs.dup
end
|
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
10
11
12
|
# File 'lib/bureaucrat/widgets.rb', line 10
def attrs
@attrs
end
|
#is_required ⇒ Object
Returns the value of attribute is_required.
9
10
11
|
# File 'lib/bureaucrat/widgets.rb', line 9
def is_required
@is_required
end
|
Class Method Details
.id_for_label(id_) ⇒ Object
35
36
37
|
# File 'lib/bureaucrat/widgets.rb', line 35
def self.id_for_label(id_)
id_
end
|
Instance Method Details
#build_attrs(extra_attrs = nil, options = {}) ⇒ Object
25
26
27
28
29
|
# File 'lib/bureaucrat/widgets.rb', line 25
def build_attrs( = nil, options = {})
attrs = @attrs.merge(options)
attrs.update() if
attrs
end
|
#has_changed?(initial, data) ⇒ Boolean
39
40
41
42
43
|
# File 'lib/bureaucrat/widgets.rb', line 39
def has_changed?(initial, data)
data_value = data || ''
initial_value = initial || ''
initial_value != data_value
end
|
#hidden? ⇒ Boolean
49
50
51
|
# File 'lib/bureaucrat/widgets.rb', line 49
def hidden?
false
end
|
#initialize_copy(original) ⇒ Object
16
17
18
19
|
# File 'lib/bureaucrat/widgets.rb', line 16
def initialize_copy(original)
super(original)
@attrs = original.attrs.dup
end
|
#needs_multipart? ⇒ Boolean
45
46
47
|
# File 'lib/bureaucrat/widgets.rb', line 45
def needs_multipart?
false
end
|
#render(name, value, attrs = nil) ⇒ Object
21
22
23
|
# File 'lib/bureaucrat/widgets.rb', line 21
def render(name, value, attrs = nil)
raise NotImplementedError
end
|
31
32
33
|
# File 'lib/bureaucrat/widgets.rb', line 31
def value_from_formdata(data, name)
data[name]
end
|