Class: BBLib::LazyClass

Inherits:
Object
  • Object
show all
Extended by:
Attr, Hooks
Defined in:
lib/object/lazy_class.rb

Direct Known Subclasses

FuzzyMatcher, TaskTimer

Instance Method Summary collapse

Methods included from Hooks

add_after_hook, add_before_hook, after, after_hooked_methods, after_hooks, after_hooks_for, before, before_hooked_methods, before_hooks, before_hooks_for, method_added

Constructor Details

#initialize(*args) ⇒ LazyClass

Returns a new instance of LazyClass.



9
10
11
12
13
# File 'lib/object/lazy_class.rb', line 9

def initialize *args
  _pre_setup
  lazy_setup
  _lazy_init(*args)
end

Instance Method Details

#serializeObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/object/lazy_class.rb', line 15

def serialize
  _serialize_fields.map do |name, h|
    value = send(h[:method])
    if !h[:always] && value == h[:ignore]
      nil
    else
      [ name, value ]
    end
  end.reject(&:nil?).to_h
end