Class: JSONCop::Model::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/jsoncop/model/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Model

Returns a new instance of Model.



9
10
11
12
13
14
# File 'lib/jsoncop/model/model.rb', line 9

def initialize(name)
    @name = name.gsub(/\s+/, "")
    @attributes = []
    @transformers = []
    @attr_json_hash = {}
end

Instance Attribute Details

#attr_json_hashObject

Returns the value of attribute attr_json_hash.



7
8
9
# File 'lib/jsoncop/model/model.rb', line 7

def attr_json_hash
  @attr_json_hash
end

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/jsoncop/model/model.rb', line 5

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/jsoncop/model/model.rb', line 4

def name
  @name
end

#transformersObject

Returns the value of attribute transformers.



6
7
8
# File 'lib/jsoncop/model/model.rb', line 6

def transformers
  @transformers
end

Instance Method Details

#key_value_pairObject



16
17
18
# File 'lib/jsoncop/model/model.rb', line 16

def key_value_pair
  attributes.map { |attribute| "#{attribute.name}: #{attribute.name}" }.join(", ")
end