Class: Doodle::DoodleAttribute
- Extended by:
- ClassMethods
- Defined in:
- lib/doodle/attribute.rb
Overview
Attribute is itself a Doodle object that is created by #has and added to the #attributes collection in an object’s DoodleInfo
It is used to provide a context for defining #must and #from rules
Direct Known Subclasses
App::Option, AttributeCollector, Doodle::DataTypes::DataType
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#abstract ⇒ Object
temporarily fake existence of abstract attribute - later has :abstract overrides this.
-
#default_defined? ⇒ Boolean
has default been defined?.
-
#init_defined? ⇒ Boolean
has default been defined?.
-
#optional? ⇒ Boolean
is this attribute optional? true if it has a default defined for it.
-
#readonly ⇒ Object
temporarily fake existence of readonly attribute.
-
#required? ⇒ Boolean
an attribute is required if it has no default or initial value defined for it.
-
#validate!(all = true) ⇒ Object
hack: bump off
validate!
for Attributes - maybe better way of doing this however, without this, tries to validate Attribute to :kind specified, e.g.
Methods included from ClassMethods
Methods inherited from Doodle
TypedArray, raise_exception_on_error, raise_exception_on_error=
Methods included from ClassMethods
Methods included from JSON
Methods included from Core::ModuleMethods
Instance Method Details
#abstract ⇒ Object
temporarily fake existence of abstract attribute - later has :abstract overrides this
134 135 136 |
# File 'lib/doodle/attribute.rb', line 134 def abstract @abstract = false end |
#default_defined? ⇒ Boolean
has default been defined?
109 110 111 |
# File 'lib/doodle/attribute.rb', line 109 def default_defined? ivar_defined?(:default) end |
#init_defined? ⇒ Boolean
has default been defined?
114 115 116 |
# File 'lib/doodle/attribute.rb', line 114 def init_defined? ivar_defined?(:init) end |
#optional? ⇒ Boolean
is this attribute optional? true if it has a default defined for it
119 120 121 |
# File 'lib/doodle/attribute.rb', line 119 def optional? default_defined? or init_defined? end |
#readonly ⇒ Object
temporarily fake existence of readonly attribute
139 140 141 |
# File 'lib/doodle/attribute.rb', line 139 def readonly false end |
#required? ⇒ Boolean
an attribute is required if it has no default or initial value defined for it
124 125 126 127 |
# File 'lib/doodle/attribute.rb', line 124 def required? # d { [:default?, self.class, self.name, instance_variable_defined?("@default"), @default] } !optional? end |
#validate!(all = true) ⇒ Object
hack: bump off validate!
for Attributes - maybe better way of doing this however, without this, tries to validate Attribute to :kind specified, e.g. if you have
has :date, :kind => Date
it will fail because Attribute is not a kind of Date - obviously, I have to think about this some more :S
at least, I could hand roll a custom validate! method for Attribute
105 106 |
# File 'lib/doodle/attribute.rb', line 105 def validate!(all = true) end |