Class: ADSL::Extract::Rails::PartiallyUnknownHash

Inherits:
MetaUnknown show all
Defined in:
lib/adsl/extract/rails/other_meta.rb

Instance Method Summary collapse

Methods inherited from MetaUnknown

#adsl_ast, #respond_to?, #to_s

Constructor Details

#initialize(options = {}) ⇒ PartiallyUnknownHash

Returns a new instance of PartiallyUnknownHash.



33
34
35
# File 'lib/adsl/extract/rails/other_meta.rb', line 33

def initialize(options = {})
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



45
46
47
48
49
50
51
52
# File 'lib/adsl/extract/rails/other_meta.rb', line 45

def method_missing(method, *args, &block)
  return @options[method] if @options.include? method
  if method.to_s =~ /^.*=$/
    short_method = method.to_s[0..-2].to_sym
    return @options[short_method] if @options.include? short_method
  end
  super
end

Instance Method Details

#[](arg) ⇒ Object



37
38
39
# File 'lib/adsl/extract/rails/other_meta.rb', line 37

def [](arg)
  @options[arg] || MetaUnknown.new
end

#[]=(key, val) ⇒ Object



41
42
43
# File 'lib/adsl/extract/rails/other_meta.rb', line 41

def []=(key, val)
  @options[key] = val
end