Module: Perron::Resource::Sourceable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Perron::Resource
- Defined in:
- lib/perron/resource/sourceable.rb
Instance Method Summary collapse
Instance Method Details
#source_backed? ⇒ Boolean
66 |
# File 'lib/perron/resource/sourceable.rb', line 66 def source_backed? = self.class.source_backed? |
#source_template(sources) ⇒ Object
81 82 83 |
# File 'lib/perron/resource/sourceable.rb', line 81 def source_template(sources) raise NotImplementedError, "#{self.class.name} must implement #source_template" end |
#sources ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/perron/resource/sourceable.rb', line 68 def sources @sources ||= begin data = self.class.source_definitions.each_with_object({}) do |(name, ), hash| primary_key = [:primary_key] singular_name = name.to_s.singularize identifier = frontmatter["#{singular_name}_#{primary_key}"] hash[name] = Perron::Site.data.public_send(name).find { it.public_send(primary_key).to_s == identifier.to_s } end Source.new(data) end end |