Class: PikoModel::Model

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/piko_model/model.rb

Constant Summary collapse

@@registered_fields =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Model

Returns a new instance of Model.



37
38
39
40
41
# File 'lib/piko_model/model.rb', line 37

def initialize(params = {})
  @values = {}
  @missing_fields = []
  fill_data(Dothash::Hash.with_dots(params))
end

Instance Attribute Details

#missing_fieldsObject (readonly)

Returns the value of attribute missing_fields.



29
30
31
# File 'lib/piko_model/model.rb', line 29

def missing_fields
  @missing_fields
end

Class Method Details

.field(name, default: Required) ⇒ Object



33
34
35
# File 'lib/piko_model/model.rb', line 33

def self.field(name, default: Required)
  @@registered_fields << { name: name, default: default }
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/piko_model/model.rb', line 43

def valid?
  @missing_fields.empty?
end