Class: ActiveRecordGraphExtractor::Configuration
- Inherits:
-
Object
- Object
- ActiveRecordGraphExtractor::Configuration
- Defined in:
- lib/activerecord_graph_extractor/configuration.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#custom_serializers ⇒ Object
Returns the value of attribute custom_serializers.
-
#excluded_models ⇒ Object
Returns the value of attribute excluded_models.
-
#excluded_relationships ⇒ Object
Returns the value of attribute excluded_relationships.
-
#handle_circular_references ⇒ Object
Returns the value of attribute handle_circular_references.
-
#included_models ⇒ Object
Returns the value of attribute included_models.
-
#included_relationships ⇒ Object
Returns the value of attribute included_relationships.
-
#max_depth ⇒ Object
Returns the value of attribute max_depth.
-
#primary_key_strategy ⇒ Object
Returns the value of attribute primary_key_strategy.
-
#progress_enabled ⇒ Object
Returns the value of attribute progress_enabled.
-
#skip_missing_models ⇒ Object
Returns the value of attribute skip_missing_models.
-
#skip_non_primary_database_models ⇒ Object
Returns the value of attribute skip_non_primary_database_models.
-
#stream_json ⇒ Object
Returns the value of attribute stream_json.
-
#use_transactions ⇒ Object
Returns the value of attribute use_transactions.
-
#validate_records ⇒ Object
Returns the value of attribute validate_records.
Class Method Summary collapse
Instance Method Summary collapse
- #add_custom_serializer(model, serializer = nil, &block) ⇒ Object
- #exclude_model(model) ⇒ Object
- #exclude_relationship(relationship) ⇒ Object
- #include_model(model) ⇒ Object
- #include_relationship(relationship) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #model_included?(model_name) ⇒ Boolean
- #relationship_included?(relationship_name) ⇒ Boolean
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 11 def initialize reset! end |
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def batch_size @batch_size end |
#custom_serializers ⇒ Object
Returns the value of attribute custom_serializers.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def custom_serializers @custom_serializers end |
#excluded_models ⇒ Object
Returns the value of attribute excluded_models.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def excluded_models @excluded_models end |
#excluded_relationships ⇒ Object
Returns the value of attribute excluded_relationships.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def excluded_relationships @excluded_relationships end |
#handle_circular_references ⇒ Object
Returns the value of attribute handle_circular_references.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def handle_circular_references @handle_circular_references end |
#included_models ⇒ Object
Returns the value of attribute included_models.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def included_models @included_models end |
#included_relationships ⇒ Object
Returns the value of attribute included_relationships.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def included_relationships @included_relationships end |
#max_depth ⇒ Object
Returns the value of attribute max_depth.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def max_depth @max_depth end |
#primary_key_strategy ⇒ Object
Returns the value of attribute primary_key_strategy.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def primary_key_strategy @primary_key_strategy end |
#progress_enabled ⇒ Object
Returns the value of attribute progress_enabled.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def progress_enabled @progress_enabled end |
#skip_missing_models ⇒ Object
Returns the value of attribute skip_missing_models.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def skip_missing_models @skip_missing_models end |
#skip_non_primary_database_models ⇒ Object
Returns the value of attribute skip_non_primary_database_models.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def skip_non_primary_database_models @skip_non_primary_database_models end |
#stream_json ⇒ Object
Returns the value of attribute stream_json.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def stream_json @stream_json end |
#use_transactions ⇒ Object
Returns the value of attribute use_transactions.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def use_transactions @use_transactions end |
#validate_records ⇒ Object
Returns the value of attribute validate_records.
5 6 7 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 5 def validate_records @validate_records end |
Class Method Details
.configuration ⇒ Object
90 91 92 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 90 def configuration @configuration ||= new end |
.configure {|configuration| ... } ⇒ Object
86 87 88 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 86 def configure yield(configuration) end |
.reset! ⇒ Object
94 95 96 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 94 def reset! @configuration = new end |
Instance Method Details
#add_custom_serializer(model, serializer = nil, &block) ⇒ Object
68 69 70 71 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 68 def add_custom_serializer(model, serializer = nil, &block) model_name = model.is_a?(Class) ? model.name : model.to_s @custom_serializers[model_name] = serializer || block end |
#exclude_model(model) ⇒ Object
55 56 57 58 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 55 def exclude_model(model) model_name = model.is_a?(Class) ? model.name : model.to_s @excluded_models << model_name unless @excluded_models.include?(model_name) end |
#exclude_relationship(relationship) ⇒ Object
64 65 66 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 64 def exclude_relationship(relationship) @excluded_relationships << relationship.to_s unless @excluded_relationships.include?(relationship.to_s) end |
#include_model(model) ⇒ Object
50 51 52 53 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 50 def include_model(model) model_name = model.is_a?(Class) ? model.name : model.to_s @included_models << model_name unless @included_models.include?(model_name) end |
#include_relationship(relationship) ⇒ Object
60 61 62 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 60 def include_relationship(relationship) @included_relationships << relationship.to_s unless @included_relationships.include?(relationship.to_s) end |
#model_included?(model_name) ⇒ Boolean
73 74 75 76 77 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 73 def model_included?(model_name) return false if @excluded_models.include?(model_name.to_s) return true if @included_models.empty? @included_models.include?(model_name.to_s) end |
#relationship_included?(relationship_name) ⇒ Boolean
79 80 81 82 83 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 79 def relationship_included?(relationship_name) return false if @excluded_relationships.include?(relationship_name.to_s) return true if @included_relationships.empty? @included_relationships.include?(relationship_name.to_s) end |
#reset! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/activerecord_graph_extractor/configuration.rb', line 15 def reset! @max_depth = 5 @batch_size = 1000 @progress_enabled = true @stream_json = false @validate_records = true @use_transactions = true @handle_circular_references = true @skip_missing_models = true @skip_non_primary_database_models = true @included_models = [] @excluded_models = [] @included_relationships = [] @excluded_relationships = [] @custom_serializers = {} @primary_key_strategy = :generate_new end |