Class: NRSER::Types::Attrs
Instance Method Summary collapse
- #default_name ⇒ Object
-
#initialize(attrs, **options) ⇒ Attrs
constructor
A new instance of Attrs.
- #test(value) ⇒ Object
Methods inherited from Type
#check, #from_data, #from_s, #has_from_data?, #has_from_s?, #has_to_data?, #name, #respond_to?, short_name, #to_data, #to_s
Constructor Details
Instance Method Details
#default_name ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/nrser/types/attrs.rb', line 16 def default_name attrs_str = @attrs.map { |name, type| "#{ name }=#{ type.name }" }.join(', ') "#{ self.class.short_name } #{ attrs_str }" end |
#test(value) ⇒ Object
24 25 26 27 28 |
# File 'lib/nrser/types/attrs.rb', line 24 def test value @attrs.all? { |name, type| value.respond_to?(name) && type.test(value.method(name).call) } end |