Module: ActiveType::VirtualAttributes::ClassMethods
- Defined in:
- lib/active_type/virtual_attributes.rb
Instance Method Summary collapse
- #_has_virtual_column?(name) ⇒ Boolean
- #_virtual_column(name) ⇒ Object
- #_virtual_column_names ⇒ Object
- #at_attribute(name, *args) ⇒ Object
- #generated_virtual_attribute_methods ⇒ Object
Instance Method Details
#_has_virtual_column?(name) ⇒ Boolean
324 325 326 327 328 329 330 331 332 |
# File 'lib/active_type/virtual_attributes.rb', line 324 def _has_virtual_column?(name) virtual_columns_hash.has_key?(name.to_s) || begin if defined?(super) super else false end end end |
#_virtual_column(name) ⇒ Object
304 305 306 307 308 309 310 311 312 |
# File 'lib/active_type/virtual_attributes.rb', line 304 def _virtual_column(name) virtual_columns_hash[name.to_s] || begin if defined?(super) super else raise MissingAttributeError.new("Undefined attribute '#{name}'") end end end |
#_virtual_column_names ⇒ Object
314 315 316 317 318 319 320 321 322 |
# File 'lib/active_type/virtual_attributes.rb', line 314 def _virtual_column_names @virtual_column_names ||= begin names = virtual_columns_hash.keys if defined?(super) names += super end names end end |
#at_attribute(name, *args) ⇒ Object
342 343 344 345 346 347 |
# File 'lib/active_type/virtual_attributes.rb', line 342 def at_attribute(name, *args) = args. type = args.first Builder.new(self, generated_virtual_attribute_methods).build(name, type, ) end |
#generated_virtual_attribute_methods ⇒ Object
334 335 336 337 338 339 340 |
# File 'lib/active_type/virtual_attributes.rb', line 334 def generated_virtual_attribute_methods @generated_virtual_attribute_methods ||= begin mod = Module.new include mod mod end end |