Class: Olelo::Attributes::AttributeDSL
- Includes:
- Util
- Defined in:
- lib/olelo/attributes.rb
Overview
DSL class used to initialize AttributeGroup
Instance Method Summary collapse
- #boolean(name) ⇒ Object
- #enum(name, values = nil, &block) ⇒ Object
-
#group(name) { ... } ⇒ void
Define attribute group.
-
#initialize(group) { ... } ⇒ AttributeDSL
constructor
Initialize DSL with ‘group`.
- #integer(name) ⇒ Object
- #list(name) ⇒ Object
- #string(name, values = nil, &block) ⇒ Object
Methods included from Util
#check, #decode64, #deep_copy, #encode64, #escape, #escape_html, #escape_javascript, included, #md5, #no_cache?, #sha256, #titlecase, #truncate, #unescape, #unescape_backslash, #unescape_html, #valid_xml_chars?, #yaml_dump, #yaml_load, #yaml_load_file
Constructor Details
#initialize(group) { ... } ⇒ AttributeDSL
Initialize DSL with ‘group`
191 192 193 194 |
# File 'lib/olelo/attributes.rb', line 191 def initialize(group, &block) @group = group instance_eval(&block) end |
Instance Method Details
#boolean(name) ⇒ Object
208 209 210 |
# File 'lib/olelo/attributes.rb', line 208 def boolean(name) @group.children[name.to_s] = Attribute::Boolean.new(@group, name) end |
#enum(name, values = nil, &block) ⇒ Object
216 217 218 |
# File 'lib/olelo/attributes.rb', line 216 def enum(name, values = nil, &block) @group.children[name.to_s] = Attribute::Enum.new(@group, name, block ? block : values) end |
#group(name) { ... } ⇒ void
This method returns an undefined value.
Define attribute group
226 227 228 |
# File 'lib/olelo/attributes.rb', line 226 def group(name, &block) AttributeDSL.new(@group.children[name.to_s] ||= AttributeGroup.new(@group, name), &block) end |
#integer(name) ⇒ Object
204 205 206 |
# File 'lib/olelo/attributes.rb', line 204 def integer(name) @group.children[name.to_s] = Attribute::Integer.new(@group, name) end |
#list(name) ⇒ Object
212 213 214 |
# File 'lib/olelo/attributes.rb', line 212 def list(name) @group.children[name.to_s] = Attribute::List.new(@group, name) end |
#string(name, values = nil, &block) ⇒ Object
196 197 198 199 200 201 202 |
# File 'lib/olelo/attributes.rb', line 196 def string(name, values = nil, &block) @group.children[name.to_s] = if values || block Attribute::Suggestions.new(@group, name, block ? block : values) else Attribute::String.new(@group, name) end end |