Module: YADM::Entity::DSL
- Defined in:
- lib/yadm/entity.rb
Instance Method Summary collapse
Instance Method Details
#attribute(attr_name, readonly: false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yadm/entity.rb', line 28 def attribute(attr_name, readonly: false) attr_name = attr_name.to_sym attributes.add(attr_name) define_method(attr_name) do @attributes[attr_name] end define_method("#{attr_name}=") do |new_value| @attributes[attr_name] = new_value end unless readonly end |
#attributes(*attr_names) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/yadm/entity.rb', line 42 def attributes(*attr_names) if attr_names.empty? @attributes ||= Set.new else attr_names.each do |attr_name| attribute(attr_name) end end end |