Module: Ahora::Representation::Definition
- Included in:
- Ahora::Representation
- Defined in:
- lib/ahora/representation.rb
Instance Method Summary collapse
- #attribute(*names) ⇒ Object
-
#attribute_selector(name) ⇒ Object
override in subclasses for e.g.
- #boolean(*names) ⇒ Object
- #date(*names) ⇒ Object
- #element ⇒ Object
- #float(*names) ⇒ Object
- #integer(*names) ⇒ Object
- #string(*names) ⇒ Object
-
#time(*names) ⇒ Object
FIXME test.
Instance Method Details
#attribute(*names) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ahora/representation.rb', line 28 def attribute(*names) names = names.flatten parser = names.pop if names.last.is_a?(Proc) names.each do |name| if Hash === name selector, name = name.first else selector = attribute_selector(name) end element selector => name.to_s, :with => parser end end |
#attribute_selector(name) ⇒ Object
override in subclasses for e.g. camelCase support
42 43 44 |
# File 'lib/ahora/representation.rb', line 42 def attribute_selector(name) name.to_s end |
#boolean(*names) ⇒ Object
67 68 69 |
# File 'lib/ahora/representation.rb', line 67 def boolean(*names) attribute(names, BOOL_PARSER) end |
#date(*names) ⇒ Object
58 59 60 |
# File 'lib/ahora/representation.rb', line 58 def date(*names) attribute(names, DATE_PARSER) end |
#element ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ahora/representation.rb', line 20 def element(*) name = super define_method "#{name}?" do !!instance_variable_get("@#{name}") end name end |
#float(*names) ⇒ Object
54 55 56 |
# File 'lib/ahora/representation.rb', line 54 def float(*names) attribute(names, FLOAT_PARSER) end |
#integer(*names) ⇒ Object
50 51 52 |
# File 'lib/ahora/representation.rb', line 50 def integer(*names) attribute(names, INTEGER_PARSER) end |
#string(*names) ⇒ Object
46 47 48 |
# File 'lib/ahora/representation.rb', line 46 def string(*names) attribute(names, STRING_PARSER) end |
#time(*names) ⇒ Object
FIXME test
63 64 65 |
# File 'lib/ahora/representation.rb', line 63 def time(*names) attribute(names, TIME_PARSER) end |