Class: Fabrique::DataBean

Inherits:
BasicObject
Defined in:
lib/fabrique/data_bean.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash, name = nil) ⇒ DataBean

Returns a new instance of DataBean.



7
8
9
10
# File 'lib/fabrique/data_bean.rb', line 7

def initialize(hash, name = nil)
  @hash = hash
  @name = name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object Also known as: send



12
13
14
15
16
17
18
19
# File 'lib/fabrique/data_bean.rb', line 12

def method_missing(sym, *args)
  key = include?(sym)

  raise_no_method_error(sym) if key.nil?
  raise_argument_error(args) unless args.empty?

  glide(sym, fetch(sym))
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/fabrique/data_bean.rb', line 23

def to_s
  @name or ::Kernel.sprintf("0x%014x", __id__)
end