lib/moblues/data_model/attribute.rb in moblues-0.3.0 vs lib/moblues/data_model/attribute.rb in moblues-0.4.0

- old
+ new

@@ -1,14 +1,17 @@ require 'extensions/hash' module Moblues module DataModel - class Attribute < Struct.new(:name, :type) + class Attribute < Struct.new(:name, :type, :optional) def initialize(params) p = params.compact + optional = false + optional = p.fetch(:optional) if p.key?(:optional) super( p.fetch(:name), - p.fetch(:type) + p.fetch(:type), + optional ) end end end end