Module: Servactory::TestKit::Rspec::Matchers::Concerns::AttributeDataAccess::InstanceMethods
- Defined in:
- lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb
Overview
Instance methods added by this concern.
Instance Method Summary collapse
-
#attribute_data ⇒ Hash
Returns the attribute definition data hash.
-
#attribute_name ⇒ Symbol?
The attribute name from context.
-
#attribute_type ⇒ Symbol?
The attribute type from context.
-
#attribute_type_plural ⇒ Symbol?
The pluralized attribute type from context.
-
#described_class ⇒ Class?
The Servactory service class from context.
-
#fetch_option(key, default = nil) ⇒ Object
Fetches a specific option from attribute data.
-
#i18n_root_key ⇒ String?
The i18n root key from context.
-
#option_present?(key) ⇒ Boolean
Checks if an option is present and has a meaningful value.
Instance Method Details
#attribute_data ⇒ Hash
Returns the attribute definition data hash.
68 69 70 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 68 def attribute_data context.attribute_data end |
#attribute_name ⇒ Symbol?
Returns The attribute name from context.
57 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 57 def attribute_name = context&.attribute_name |
#attribute_type ⇒ Symbol?
Returns The attribute type from context.
54 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 54 def attribute_type = context&.attribute_type |
#attribute_type_plural ⇒ Symbol?
Returns The pluralized attribute type from context.
60 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 60 def attribute_type_plural = context&.attribute_type_plural |
#described_class ⇒ Class?
Returns The Servactory service class from context.
51 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 51 def described_class = context&.described_class |
#fetch_option(key, default = nil) ⇒ Object
Fetches a specific option from attribute data.
77 78 79 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 77 def fetch_option(key, default = nil) attribute_data.fetch(key, default) end |
#i18n_root_key ⇒ String?
Returns The i18n root key from context.
63 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 63 def i18n_root_key = context&.i18n_root_key |
#option_present?(key) ⇒ Boolean
Checks if an option is present and has a meaningful value.
Returns false if the key doesn’t exist, or if the value is nil or empty (for collections).
88 89 90 91 92 93 |
# File 'lib/servactory/test_kit/rspec/matchers/concerns/attribute_data_access.rb', line 88 def option_present?(key) return false unless attribute_data.key?(key) value = attribute_data[key] !value.nil? && (!value.respond_to?(:empty?) || !value.empty?) end |