Class: Immutabler::DSL::PropsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/immutabler/dsl/props_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(props, &block) ⇒ PropsBuilder

Returns a new instance of PropsBuilder.



6
7
8
9
# File 'lib/immutabler/dsl/props_builder.rb', line 6

def initialize(props, &block)
  @props = props
  instance_eval(&block)
end

Instance Method Details

#prop(name, type, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/immutabler/dsl/props_builder.rb', line 11

def prop(name, type, options={})
  prop_options = {}
  prop_options[:is_ref] = options[:is_ref] if options.key?(:is_ref)
  prop_options[:ref_type] = options[:ref_type] if options.key?(:ref_type)
  prop_options[:name_prefix] = options[:name_prefix] if options.key?(:name_prefix)
  prop_options[:is_id] = options[:is_id] if options.key?(:is_id)
  @props << Prop.new(name.to_s, type.to_s, prop_options)
end