Class: XDry::OAttribute
- Inherits:
-
Object
- Object
- XDry::OAttribute
- Defined in:
- lib/xdry/parsing/model.rb
Instance Attribute Summary collapse
-
#field_def ⇒ Object
readonly
Returns the value of attribute field_def.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_field_def!(field_def) ⇒ Object
- #add_property_def!(property_def) ⇒ Object
- #add_synthesize!(synthesize) ⇒ Object
- #field_name ⇒ Object
- #getter_selector ⇒ Object
- #has_field_def? ⇒ Boolean
- #has_property_def? ⇒ Boolean
- #has_synthesize? ⇒ Boolean
-
#initialize(oclass, name) ⇒ OAttribute
constructor
A new instance of OAttribute.
- #new_field_def ⇒ Object
- #new_property_def ⇒ Object
- #new_synthesize ⇒ Object
- #persistent? ⇒ Boolean
- #to_s ⇒ Object
- #type ⇒ Object
- #type_known? ⇒ Boolean
- #wants_constructor? ⇒ Boolean
- #wants_property? ⇒ Boolean
Constructor Details
#initialize(oclass, name) ⇒ OAttribute
Returns a new instance of OAttribute.
142 143 144 145 146 147 148 |
# File 'lib/xdry/parsing/model.rb', line 142 def initialize oclass, name @oclass, @name = oclass, name @field_def = nil @property_def = nil @synthesizes = [] end |
Instance Attribute Details
#field_def ⇒ Object (readonly)
Returns the value of attribute field_def.
140 141 142 |
# File 'lib/xdry/parsing/model.rb', line 140 def field_def @field_def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
139 140 141 |
# File 'lib/xdry/parsing/model.rb', line 139 def name @name end |
Instance Method Details
#add_field_def!(field_def) ⇒ Object
158 159 160 |
# File 'lib/xdry/parsing/model.rb', line 158 def add_field_def! field_def @field_def = field_def end |
#add_property_def!(property_def) ⇒ Object
162 163 164 |
# File 'lib/xdry/parsing/model.rb', line 162 def add_property_def! property_def @property_def = property_def end |
#add_synthesize!(synthesize) ⇒ Object
166 167 168 |
# File 'lib/xdry/parsing/model.rb', line 166 def add_synthesize! synthesize @synthesizes << synthesize end |
#field_name ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/xdry/parsing/model.rb', line 150 def field_name if @field_def @field_def.name else FIELD_PREFIX + name end end |
#getter_selector ⇒ Object
210 211 212 213 |
# File 'lib/xdry/parsing/model.rb', line 210 def getter_selector # FIXME: need to account for a possible selector override declared in @property @name end |
#has_field_def? ⇒ Boolean
170 171 172 |
# File 'lib/xdry/parsing/model.rb', line 170 def has_field_def? not @field_def.nil? end |
#has_property_def? ⇒ Boolean
174 175 176 |
# File 'lib/xdry/parsing/model.rb', line 174 def has_property_def? not @property_def.nil? end |
#has_synthesize? ⇒ Boolean
178 179 180 |
# File 'lib/xdry/parsing/model.rb', line 178 def has_synthesize? not @synthesizes.empty? end |
#new_field_def ⇒ Object
186 187 188 |
# File 'lib/xdry/parsing/model.rb', line 186 def new_field_def NFieldDef.new(field_name, type) end |
#new_property_def ⇒ Object
182 183 184 |
# File 'lib/xdry/parsing/model.rb', line 182 def new_property_def NPropertyDef.new(name, type) end |
#new_synthesize ⇒ Object
190 191 192 |
# File 'lib/xdry/parsing/model.rb', line 190 def new_synthesize NSynthesize.new([SynthesizeItem.new(name, (field_name == name ? nil : field_name) )]) end |
#persistent? ⇒ Boolean
194 195 196 |
# File 'lib/xdry/parsing/model.rb', line 194 def persistent? @field_def && @field_def.persistent? end |
#to_s ⇒ Object
225 226 227 228 229 |
# File 'lib/xdry/parsing/model.rb', line 225 def to_s traits = [] traits << field_name if has_field_def? "#{type} #{name}" + (traits.empty? ? "" : " (" + traits.join(", ") + ")") end |
#type ⇒ Object
215 216 217 218 219 220 221 222 223 |
# File 'lib/xdry/parsing/model.rb', line 215 def type if @property_def @property_def.type elsif @field_def @field_def.type else nil end end |
#type_known? ⇒ Boolean
198 199 200 |
# File 'lib/xdry/parsing/model.rb', line 198 def type_known? not type.nil? end |
#wants_constructor? ⇒ Boolean
206 207 208 |
# File 'lib/xdry/parsing/model.rb', line 206 def wants_constructor? has_field_def? && field_def.wants_constructor? end |
#wants_property? ⇒ Boolean
202 203 204 |
# File 'lib/xdry/parsing/model.rb', line 202 def wants_property? has_field_def? && field_def.wants_property? end |