Module: Applitools::Jsonable::ClassMethods

Defined in:
lib/applitools/core/jsonable.rb

Instance Method Summary collapse

Instance Method Details

#json_field(*args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/applitools/core/jsonable.rb', line 18

def json_field(*args)
  options = Applitools::Utils.extract_options!(args)
  field = args.first.to_sym
  options = { method: field }.merge! options
  json_methods[field] = options[:method]
  return unless options[:method].to_sym == field
  attr_accessor field
  ruby_style_field = Applitools::Utils.underscore(field.to_s)
  return if field.to_s == ruby_style_field
  define_method(ruby_style_field) do
    send(field)
  end
  define_method("#{ruby_style_field}=") do |v|
    send("#{field}=", v)
  end
end

#json_fields(*args) ⇒ Object



35
36
37
# File 'lib/applitools/core/jsonable.rb', line 35

def json_fields(*args)
  args.each { |m| json_field m }
end

#wrap_data(&block) ⇒ Object



39
40
41
# File 'lib/applitools/core/jsonable.rb', line 39

def wrap_data(&block)
  @wrap_data_block = block
end