Module: Applitools::Jsonable::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#json_field(*args) ⇒ Object



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

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]
  if options[:method].to_sym == field
    attr_accessor field
    ruby_style_field = Applitools::Utils.underscore(field.to_s)
    unless 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
  end
end

#json_fields(*args) ⇒ Object



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

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