Module: ActiveGraph::Shared::Property::ClassMethods
- Extended by:
 - Forwardable
 
- Defined in:
 - lib/active_graph/shared/property.rb
 
Constant Summary collapse
- VALID_PROPERTY_OPTIONS =
 %w(type default index constraint serializer typecaster).map(&:to_sym)
Instance Method Summary collapse
- 
  
    
      #attributes_nil_hash  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
an extra call to a slow dependency method.
 - #build_property(name, options) ⇒ Object
 - #declared_properties ⇒ Object
 - #extract_association_attributes!(props) ⇒ Object
 - #inherit_property(name, attr_def, options = {}) ⇒ Object
 - 
  
    
      #property(name, options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Defines a property on the class.
 - #undef_property(name) ⇒ Object
 
Instance Method Details
#attributes_nil_hash ⇒ Hash
an extra call to a slow dependency method.
      205 206 207  | 
    
      # File 'lib/active_graph/shared/property.rb', line 205 def attributes_nil_hash declared_properties.attributes_nil_hash end  | 
  
#build_property(name, options) ⇒ Object
      177 178 179 180 181 182 183 184 185 186 187 188 189 190 191  | 
    
      # File 'lib/active_graph/shared/property.rb', line 177 def build_property(name, ) decl_prop = DeclaredProperty.new(name, ).tap do |prop| prop.register declared_properties.register(prop) yield name constraint_or_index(name, ) end # If this class has already been inherited, make sure subclasses inherit property subclasses.each do |klass| klass.inherit_property name, decl_prop.clone, declared_properties[name]. end decl_prop end  | 
  
#declared_properties ⇒ Object
      199 200 201  | 
    
      # File 'lib/active_graph/shared/property.rb', line 199 def declared_properties @_declared_properties ||= DeclaredProperties.new(self) end  | 
  
#extract_association_attributes!(props) ⇒ Object
      209 210 211  | 
    
      # File 'lib/active_graph/shared/property.rb', line 209 def extract_association_attributes!(props) props end  | 
  
#inherit_property(name, attr_def, options = {}) ⇒ Object
      171 172 173 174 175  | 
    
      # File 'lib/active_graph/shared/property.rb', line 171 def inherit_property(name, attr_def, = {}) build_property(name, ) do |prop_name| attributes[prop_name] = attr_def end end  | 
  
#property(name, options = {}) ⇒ Object
Defines a property on the class
See active_attr gem for allowed options, e.g which type Notice, in ActiveGraph you don’t have to declare properties before using them, see the ActiveGraph::Coree api.
      160 161 162 163 164 165 166  | 
    
      # File 'lib/active_graph/shared/property.rb', line 160 def property(name, = {}) invalid_option_keys = .keys.map(&:to_sym) - VALID_PROPERTY_OPTIONS fail ArgumentError, "Invalid options for property `#{name}` on `#{self.name}`: #{invalid_option_keys.join(', ')}" if invalid_option_keys.any? build_property(name, ) do |prop| attribute(prop) end end  | 
  
#undef_property(name) ⇒ Object
      193 194 195 196 197  | 
    
      # File 'lib/active_graph/shared/property.rb', line 193 def undef_property(name) undef_constraint_or_index(name) declared_properties.unregister(name) attribute_methods(name).each { |method| undef_method(method) } end  |