Module: Crystalball::Rails::Helpers::BaseSchemaParser

Included in:
SchemaDefinitionParser, SchemaDefinitionParser::TableContentParser
Defined in:
lib/crystalball/rails/helpers/base_schema_parser.rb

Overview

Interface for schema parsers

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)

Store info about call in hash. First argument of method call used as a key



22
23
24
25
26
27
28
29
30
# File 'lib/crystalball/rails/helpers/base_schema_parser.rb', line 22

def method_missing(method_name, *args, &block)
  name = args.shift
  add_to_hash(name, options: [method_name] + args)

  new_parser = self.class.new
  add_to_hash(name, content: new_parser.instance_exec(&block)) if block
  add_to_hash(name, content: new_parser.hash)
  new_parser
end

Instance Attribute Details

#hashHash

Returns stored info about all method calls which ended in #method_missing.

Returns:

  • (Hash)

    stored info about all method calls which ended in #method_missing



13
14
15
# File 'lib/crystalball/rails/helpers/base_schema_parser.rb', line 13

def hash
  @hash
end

Class Method Details

.parse(*_) ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/crystalball/rails/helpers/base_schema_parser.rb', line 8

def self.parse(*_)
  raise NotImplementedError
end

Instance Method Details

#initializeObject



15
16
17
# File 'lib/crystalball/rails/helpers/base_schema_parser.rb', line 15

def initialize
  @hash = {}
end