Class: Brut::CLI::Apps::New::ErbBindingDelegate

Inherits:
Object
  • Object
show all
Defined in:
lib/brut/cli/apps/new/erb_binding_delegate.rb

Overview

This exists because ERB can't working with a SimpleDelegator or Delegate.

Direct Known Subclasses

Base::ErbBinding

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options:, app_name:, versions:) ⇒ ErbBindingDelegate

Returns a new instance of ErbBindingDelegate.



5
6
7
8
9
# File 'lib/brut/cli/apps/new/erb_binding_delegate.rb', line 5

def initialize(options:, app_name:, versions:)
  @options  = options
  @app_name = app_name
  @versions = versions
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(syn, *args, &block) ⇒ Object

Not using Delegate because it won't work with ERB binding



12
13
14
15
16
17
18
# File 'lib/brut/cli/apps/new/erb_binding_delegate.rb', line 12

def method_missing(syn,*args,&block)
  if args.empty? && @options.respond_to?(syn)
    @options.send(syn)
  else
    super
  end
end

Instance Attribute Details

#app_nameObject (readonly)

Returns the value of attribute app_name.



4
5
6
# File 'lib/brut/cli/apps/new/erb_binding_delegate.rb', line 4

def app_name
  @app_name
end

#versionsObject (readonly)

Returns the value of attribute versions.



4
5
6
# File 'lib/brut/cli/apps/new/erb_binding_delegate.rb', line 4

def versions
  @versions
end

Instance Method Details

#respond_to_missing?(syn, include_all) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/brut/cli/apps/new/erb_binding_delegate.rb', line 20

def respond_to_missing?(syn,include_all)
  @options.respond_to?(syn)
end