Module: MassiveRecord::ORM::Schema::CommonInterface::ClassMethods

Defined in:
lib/massive_record/orm/schema/common_interface.rb

Instance Method Summary collapse

Instance Method Details

#attributes_schemaObject

Returns a hash where attribute names are keys and it’s field is the value.



19
20
21
# File 'lib/massive_record/orm/schema/common_interface.rb', line 19

def attributes_schema
  schema_source.present? ? schema_source.to_hash : {}
end

#default_attributes_from_schemaObject

Returns a hash with attribute name as keys, default values read from field as value.



35
36
37
38
39
# File 'lib/massive_record/orm/schema/common_interface.rb', line 35

def default_attributes_from_schema
  Hash[attributes_schema.collect { |attribute_name, field| 
    [attribute_name, field.default]
  }]
end

#known_attribute_namesObject

Returns an array of known attributes based on all fields found in schema source



27
28
29
# File 'lib/massive_record/orm/schema/common_interface.rb', line 27

def known_attribute_names
  schema_source.present? ? schema_source.attribute_names : []
end