Class: Modernize::BlockParsingContext
- Inherits:
-
Object
- Object
- Modernize::BlockParsingContext
- Defined in:
- lib/modernizer/parser.rb
Overview
Class for the context in which the block will get run
Instance Attribute Summary collapse
-
#has_version ⇒ Object
Returns the value of attribute has_version.
-
#initial_version ⇒ Object
Returns the value of attribute initial_version.
-
#order ⇒ Object
Returns the value of attribute order.
-
#translations ⇒ Object
Returns the value of attribute translations.
Instance Method Summary collapse
-
#initialize ⇒ BlockParsingContext
constructor
A new instance of BlockParsingContext.
-
#method_missing(method, *args, &block) ⇒ Object
Determines what versions there are and before + after if any.
-
#migrations ⇒ Object
Returns the struct of version block and translation sets throws an error if no block is provided for determining version.
Constructor Details
#initialize ⇒ BlockParsingContext
Returns a new instance of BlockParsingContext.
23 24 25 26 27 28 |
# File 'lib/modernizer/parser.rb', line 23 def initialize @translations = {} @initial_version = nil @has_version = false @order = :ascending end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Determines what versions there are and before + after if any.
32 33 34 35 |
# File 'lib/modernizer/parser.rb', line 32 def method_missing(method, *args, &block) raise NoMethodError.new("Undefined translation method #{method}") unless MetaMethods.respond_to?(method) MetaMethods.send(method, self, args, &block) end |
Instance Attribute Details
#has_version ⇒ Object
Returns the value of attribute has_version.
21 22 23 |
# File 'lib/modernizer/parser.rb', line 21 def has_version @has_version end |
#initial_version ⇒ Object
Returns the value of attribute initial_version.
21 22 23 |
# File 'lib/modernizer/parser.rb', line 21 def initial_version @initial_version end |
#order ⇒ Object
Returns the value of attribute order.
21 22 23 |
# File 'lib/modernizer/parser.rb', line 21 def order @order end |
#translations ⇒ Object
Returns the value of attribute translations.
21 22 23 |
# File 'lib/modernizer/parser.rb', line 21 def translations @translations end |
Instance Method Details
#migrations ⇒ Object
Returns the struct of version block and translation sets throws an error if no block is provided for determining version.
40 41 42 43 |
# File 'lib/modernizer/parser.rb', line 40 def migrations raise VersionError.new('did not provide a way to determine version') unless @has_version CompiledMigrations.new(@translations, @initial_version, @order) end |