Module: Weft::DSL::Attributes::ClassMethods
- Defined in:
- lib/weft/dsl/attributes.rb
Instance Method Summary collapse
-
#attribute(name, default: nil, **options) ⇒ Object
Declare a wire attribute.
-
#attributes ⇒ Object
Returns all declared attributes (own + inherited), preserving declaration order.
Instance Method Details
#attribute(name, default: nil, **options) ⇒ Object
Declare a wire attribute. Accepts optional default: and type: kwargs. attribute :status, default: "active", type: :string
16 17 18 19 20 |
# File 'lib/weft/dsl/attributes.rb', line 16 def attribute(name, default: nil, **) = { default: default } [:type] = [:type] if .key?(:type) own_attributes[name] = end |
#attributes ⇒ Object
Returns all declared attributes (own + inherited), preserving declaration order.
23 24 25 26 27 28 29 |
# File 'lib/weft/dsl/attributes.rb', line 23 def attributes if superclass.respond_to?(:attributes) superclass.attributes.merge(own_attributes) else own_attributes.dup end end |