Module: NumeritajTipo::Neo4j
- Includes:
- Base
- Defined in:
- lib/numeritaj_tipo/neo4j.rb,
lib/numeritaj_tipo/neo4j/type_converters/enum_converter.rb,
lib/numeritaj_tipo/neo4j/type_converters/symbol_converter.rb
Defined Under Namespace
Modules: TypeConverters
Class Method Summary collapse
Instance Method Summary collapse
- #define_enum(attribute_name, type, default_value) ⇒ Object
- #define_scopes(attribute_definition) ⇒ Object
Methods included from Base
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/numeritaj_tipo/neo4j.rb', line 9 def self.included(base) base.extend self end |
Instance Method Details
#define_enum(attribute_name, type, default_value) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/numeritaj_tipo/neo4j.rb', line 13 def define_enum(attribute_name, type, default_value) = {type: type, default: type < NumeritajTipo::EnumBase ? type.build(default_value) : default_value} .merge!(typecaster: NumeritajTipo::Neo4j::TypeConverters::SymbolConverter) if type == Symbol .merge!(typecaster: NumeritajTipo::Neo4j::TypeConverters::EnumConverter.converter_for(type)) if type < NumeritajTipo::EnumBase property attribute_name, end |
#define_scopes(attribute_definition) ⇒ Object
21 22 23 24 25 |
# File 'lib/numeritaj_tipo/neo4j.rb', line 21 def define_scopes(attribute_definition) attribute_definition.enum_values.each do |value| scope value, -> { where(attribute_definition.name => value) } end end |