Skip to content

Commit

Permalink
am i creating too many objects?
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Mar 21, 2014
1 parent 288e289 commit a493167
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Connection
def initialize(options = ENV['NEO4J_URL'] || {})
config = merge_configuration(options)
save_local_configuration(config)
@client = HTTPClient.new(config[:proxy])
@client ||= HTTPClient.new(config[:proxy])
@client.send_timeout = 1200 # 10 minutes
@client.receive_timeout = 1200
authenticate
Expand Down
50 changes: 25 additions & 25 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,31 @@ class Rest
def initialize(options = ENV['NEO4J_URL'] || {})
@connection = Connection.new(options)

@nodes = Nodes.new(@connection)
@node_properties = NodeProperties.new(@connection)
@node_relationships = NodeRelationships.new(@connection)
@other_node_relationships = OtherNodeRelationships.new(@connection)
@node_indexes = NodeIndexes.new(@connection)
@node_auto_indexes = NodeAutoIndexes.new(@connection)
@schema_indexes = SchemaIndexes.new(@connection)
@node_traversal = NodeTraversal.new(@connection)
@node_paths = NodePaths.new(@connection)
@node_labels = NodeLabels.new(@connection)

@relationships = Relationships.new(@connection)
@relationship_properties = RelationshipProperties.new(@connection)
@relationship_indexes = RelationshipIndexes.new(@connection)
@relationship_auto_indexes = RelationshipAutoIndexes.new(@connection)
@relationship_types = RelationshipTypes.new(@connection)

@cypher = Cypher.new(@connection)
@gremlin = Gremlin.new(@connection)
@extensions = Extensions.new(@connection)
@batch = Batch.new(@connection)
@clean = Clean.new(@connection)
@transactions = Transactions.new(@connection)
@spatial = Spatial.new(@connection)
@constraints = Constraints.new(@connection)
@nodes ||= Nodes.new(@connection)
@node_properties ||= NodeProperties.new(@connection)
@node_relationships ||= NodeRelationships.new(@connection)
@other_node_relationships ||= OtherNodeRelationships.new(@connection)
@node_indexes ||= NodeIndexes.new(@connection)
@node_auto_indexes ||= NodeAutoIndexes.new(@connection)
@schema_indexes ||= SchemaIndexes.new(@connection)
@node_traversal ||= NodeTraversal.new(@connection)
@node_paths ||= NodePaths.new(@connection)
@node_labels ||= NodeLabels.new(@connection)

@relationships ||= Relationships.new(@connection)
@relationship_properties ||= RelationshipProperties.new(@connection)
@relationship_indexes ||= RelationshipIndexes.new(@connection)
@relationship_auto_indexes ||= RelationshipAutoIndexes.new(@connection)
@relationship_types ||= RelationshipTypes.new(@connection)

@cypher ||= Cypher.new(@connection)
@gremlin ||= Gremlin.new(@connection)
@extensions ||= Extensions.new(@connection)
@batch ||= Batch.new(@connection)
@clean ||= Clean.new(@connection)
@transactions ||= Transactions.new(@connection)
@spatial ||= Spatial.new(@connection)
@constraints ||= Constraints.new(@connection)
end

# meta-data
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/auto_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AutoIndexes
include Neography::Rest::Helpers

def initialize(connection)
@connection = connection
@connection ||= connection
end

def get(key, value)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Batch
add_path :batch, "/batch"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def execute(*args)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Clean
add_path :clean, "/cleandb/secret-key"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def execute
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/constraints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Constraints
add_path :unique, "/schema/constraint/:label/uniqueness/:property"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def drop(label, property)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/cypher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Cypher
include Neography::Rest::Helpers

def initialize(connection)
@connection = connection
@connection ||= connection
end

def query(query, parameters = {}, cypher_options = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Extensions
include Neography::Rest::Helpers

def initialize(connection)
@connection = connection
@connection ||= connection
end

def get(path)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/gremlin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Gremlin
include Neography::Rest::Helpers

def initialize(connection)
@connection = connection
@connection ||= connection
end

def execute(script, parameters = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/neography/rest/indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class Indexes
include Neography::Rest::Helpers

def initialize(connection, index_type)
@connection = connection
@index_type = index_type
@connection ||= connection
@index_type ||= index_type
end

def list
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_labels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NodeLabels
add_path :delete, "/node/:id/labels/:label"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def list
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NodePaths
add_path :all, "/node/:id/paths"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def get(from, to, relationships, depth = 1, algorithm = "shortestPath")
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NodeRelationships
add_path :type, "/node/:id/relationships/:direction/:types"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def create(type, from, to, properties = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_traversal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NodeTraversal
add_path :traversal, "/node/:id/traverse/:type"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def traverse(id, return_type, description)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Nodes
add_path :base, "/node/:id"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def get(id)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/other_node_relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class OtherNodeRelationships
add_path :base, "/node/:id/traverse/relationship"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def get(id, other_id, direction = "all", types = [nil])
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Properties
include Neography::Rest::Helpers

def initialize(connection)
@connection = connection
@connection ||= connection
end

def set(id, properties)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/relationship_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class RelationshipTypes
add_path :all, "/relationship/types"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def list
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Relationships
add_path :base, "/relationship/:id"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def get(id)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/schema_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SchemaIndexes
add_path :drop, "/schema/index/:label/:index"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def list(label)
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/spatial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Spatial
add_path :add_to_index, "/index/node/:index"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def index
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Transactions
add_path :commit, "/transaction/:id/commit"

def initialize(connection)
@connection = connection
@connection ||= connection
end

def begin(statements = [], commit = "")
Expand Down

0 comments on commit a493167

Please sign in to comment.