Sha256: 8e5254d875677e6d71cdad25ff21b33bb9d98a8138e4b30be7acf46b868111e6

Contents?: true

Size: 793 Bytes

Versions: 29

Compression:

Stored size: 793 Bytes

Contents

module Arrest
  class Attribute
    attr_accessor :name, :read_only, :clazz, :json_name
    def initialize name, read_only, clazz
      @name = name.to_sym
      @read_only = read_only
      @clazz = clazz
      @json_name = Source.json_key_converter.key_to_json(name).to_sym
    end

    def from_hash(parent, value)
      return if value == nil
      converter = CONVERTER[@clazz]
      if converter == nil
        puts "No converter for: #{@clazz.name}"
        converter = IdentConv
      end
      converter.convert value
    end

    def to_hash value
      return nil unless value != nil
      converter = CONVERTER[@clazz]
      if converter == nil
        puts "No converter for: #{@clazz.name}"
        converter = IdentConv
      end
      converter.mk_json value
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
arrest-0.0.53 lib/arrest/attributes/attribute.rb
arrest-0.0.52 lib/arrest/attributes/attribute.rb
arrest-0.0.51 lib/arrest/attributes/attribute.rb
arrest-0.0.50 lib/arrest/attributes/attribute.rb
arrest-0.0.49 lib/arrest/attributes/attribute.rb
arrest-0.0.48 lib/arrest/attributes/attribute.rb
arrest-0.0.47 lib/arrest/attributes/attribute.rb
arrest-0.0.46 lib/arrest/attributes/attribute.rb
arrest-0.0.44 lib/arrest/attributes/attribute.rb
arrest-0.0.43 lib/arrest/attributes/attribute.rb
arrest-0.0.42 lib/arrest/attributes/attribute.rb
arrest-0.0.41 lib/arrest/attributes/attribute.rb
arrest-0.0.40 lib/arrest/attributes/attribute.rb
arrest-0.0.39 lib/arrest/attributes/attribute.rb
arrest-0.0.38 lib/arrest/attributes/attribute.rb
arrest-0.0.37 lib/arrest/attributes/attribute.rb
arrest-0.0.36 lib/arrest/attributes/attribute.rb
arrest-0.0.35 lib/arrest/attributes/attribute.rb
arrest-0.0.34 lib/arrest/attributes/attribute.rb
arrest-0.0.33 lib/arrest/attributes/attribute.rb