Module: Lims::Core::Base::AccessibleViaSuper

Defined in:
lib/lims-core/base.rb

Instance Method Summary collapse

Instance Method Details

#attributes_for_dirtyObject

Like attributes but allow class to define a version without side effet. For example attribute on a UuidResource will generate an uuid. This is the method called by dirty_key_for



34
35
36
# File 'lib/lims-core/base.rb', line 34

def attributes_for_dirty
  attributes
end

#initialize(*args, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lims-core/base.rb', line 17

def initialize(*args, &block)
  # readonly attributes are normaly not allowed in constructor
  # by Virtus. We need to call set_attributes explicitely
  options = args.extract_options!
  # we would use `options & [:row ... ]` if we could
  # but Sequel redefine Hash#& ...
  initializables = self.class.attributes.select {|a| a.options[:initializable] == true  }
  initial_options  = options.subset(initializables.map(&:name))
  set_attributes(initial_options)
  super(*args, options - initial_options, &block).tap {
  }
end