Class: Typisch::DSL::DerivedObjectContext
- Inherits:
-
ObjectContext
- Object
- ObjectContext
- Typisch::DSL::DerivedObjectContext
- Defined in:
- lib/typisch/dsl.rb
Instance Attribute Summary
Attributes inherited from ObjectContext
#properties, #property_annotations
Instance Method Summary collapse
-
#derive_all_properties ⇒ Object
derives all properties from the original type which haven’t already been derived.
- #derive_all_properties_except(*props) ⇒ Object
- #derive_properties(*names) ⇒ Object
-
#derive_property(name, *derive_args, &derive_block) ⇒ Object
use a property from the original object type being derived from.
-
#initialize(c, original_object_type) ⇒ DerivedObjectContext
constructor
A new instance of DerivedObjectContext.
Methods inherited from ObjectContext
#annotate, #method_missing, #property
Constructor Details
#initialize(c, original_object_type) ⇒ DerivedObjectContext
Returns a new instance of DerivedObjectContext.
199 200 201 202 |
# File 'lib/typisch/dsl.rb', line 199 def initialize(c, original_object_type) super(c) @original_object_type = original_object_type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Typisch::DSL::ObjectContext
Instance Method Details
#derive_all_properties ⇒ Object
derives all properties from the original type which haven’t already been derived. this is done for you by Typisch::Typed::ClassMethods#register_subtype.
217 218 219 220 221 |
# File 'lib/typisch/dsl.rb', line 217 def derive_all_properties @original_object_type.property_names_to_types.each do |name, type| property(name, type) unless @properties[name] end end |
#derive_all_properties_except(*props) ⇒ Object
223 224 225 226 227 228 |
# File 'lib/typisch/dsl.rb', line 223 def derive_all_properties_except(*props) @original_object_type.property_names_to_types.each do |name, type| next if props.include?(name) property(name, type) unless @properties[name] end end |
#derive_properties(*names) ⇒ Object
204 205 206 |
# File 'lib/typisch/dsl.rb', line 204 def derive_properties(*names) names.each {|n| derive_property(n)} end |
#derive_property(name, *derive_args, &derive_block) ⇒ Object
use a property from the original object type being derived from
209 210 211 212 213 |
# File 'lib/typisch/dsl.rb', line 209 def derive_property(name, *derive_args, &derive_block) type = @original_object_type[name] or raise "use_property: no such property #{name.inspect} on the original type" derived_type = derived_from(type, *derive_args, &derive_block) property name, derived_type end |