Module: Gearbox::SubjectMethods::InstanceMethods
- Defined in:
- lib/gearbox/mixins/subject_methods.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
- #id ⇒ Object
-
#id_method ⇒ Object
Gives us the ability to derive an id from other sources or patterns.
-
#subject_decorator ⇒ Object
Allows patterns to be used to define the subject.
Instance Method Summary collapse
- #initialize(opts = {}) ⇒ Object
-
#subject ⇒ Object
subject_decorator -> internal method -> subject subject_decorator -> lambda -> subject (base_uri + (id_method -> id)) -> subject There are several ways to create the subject.
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
29 30 31 |
# File 'lib/gearbox/mixins/subject_methods.rb', line 29 def base_uri @base_uri end |
#id ⇒ Object
36 37 38 39 |
# File 'lib/gearbox/mixins/subject_methods.rb', line 36 def id return @id if @id send(id_method) end |
#id_method ⇒ Object
Gives us the ability to derive an id from other sources or patterns. Based on the identifier patterns: patterns.dataincubator.org/book/
44 45 46 |
# File 'lib/gearbox/mixins/subject_methods.rb', line 44 def id_method @id_method end |
#subject_decorator ⇒ Object
Allows patterns to be used to define the subject.
47 48 49 |
# File 'lib/gearbox/mixins/subject_methods.rb', line 47 def subject_decorator @subject_decorator end |
Instance Method Details
#initialize(opts = {}) ⇒ Object
31 32 33 34 |
# File 'lib/gearbox/mixins/subject_methods.rb', line 31 def initialize(opts={}) super set_attributes_from_configuration_or_opts(opts, :base_uri, :id_method, :id, :subject_decorator) end |
#subject ⇒ Object
subject_decorator -> internal method -> subject subject_decorator -> lambda -> subject (base_uri + (id_method -> id)) -> subject There are several ways to create the subject. First, the subject_decorator will use whatever instance values that are set to build a pattern. Second, the base_uri and id are combined to create the subject.
Note, the id can be set directly, or set with the id_method, so UUID, or an external source, or a slug generating method can be used to generate an id.
58 59 60 61 62 63 64 |
# File 'lib/gearbox/mixins/subject_methods.rb', line 58 def subject if subject_decorator derive_subject_from_decorator else derive_subject_from_base_uri_and_id end end |