Module: Ecoportal::API::Common::Content::DoubleModel::Attributable::Simple::ClassMethods

Defined in:
lib/ecoportal/api/common/content/double_model/attributable/simple.rb

Instance Method Summary collapse

Instance Method Details

#passboolean(*methods, read_only: false) ⇒ Object

To link as a Boolean to a subjacent Hash model property

Parameters:

  • methods (Array<Symbol>)

    the method that exposes the value as well as its key in the underlying Hash model.

  • read_only (Boolean) (defaults to: false)

    should it only define the reader?



36
37
38
39
40
# File 'lib/ecoportal/api/common/content/double_model/attributable/simple.rb', line 36

def passboolean(*methods, read_only: false)
  pass_reader(*methods) {|value| value}
  pass_writer(*methods) {|value| !!value} unless read_only
  self
end

#passdate(*methods, read_only: false) ⇒ Object

To link as a Time date to a subjacent Hash model property

Parameters:

  • methods (Array<Symbol>)

    the method that exposes the value as well as its key in the underlying Hash model.

  • read_only (Boolean) (defaults to: false)

    should it only define the reader?

See Also:

  • Ecoportal::API::Common::Content::DoubleModel#passthrough


26
27
28
29
30
# File 'lib/ecoportal/api/common/content/double_model/attributable/simple.rb', line 26

def passdate(*methods, read_only: false)
  pass_reader(*methods) {|value| to_time(value)}
  pass_writer(*methods) {|value| to_time(value)&.iso8601} unless read_only
  self
end