module Rooftop::Base
Public Class Methods
included(base)
click to toggle source
# File lib/rooftop/base.rb, line 3 def self.included(base) @included_classes ||= [] @included_classes << base unless @included_classes.include?(base) base.extend ClassMethods base.include Her::Model # Paths to get to the API base.api_namespace = Rooftop::DEFAULT_API_NAMESPACE base.api_version = Rooftop::DEFAULT_API_VERSION base.setup_path! # Coercions allow you to pass a block to do something with a returned field base.include Rooftop::Coercions # Aliases allow you to specify a field (or fields) to alias base.include Rooftop::FieldAliases # Queries mixin includes a fixup for there `where()` method base.include Rooftop::Queries # Links mixin handles the _links key in a response base.include Rooftop::ResourceLinks # Pagination mixin - uses pagination metadata set in the PaginationMiddleware base.include Rooftop::Pagination # Use the API instance we have configured - in a proc because we can't control load order base.send(:use_api,->{Rooftop.configuration.connection}) # Turn calls to `content` into a collection of Rooftop::ContentField objects base.include Rooftop::Content # Add some useful scopes base.include Rooftop::Scopes # Coerce the title field from an object to a string base.include Rooftop::Coercions::TitleCoercion # Date and Modified fields are pretty universal in responses from WP, so we can automatically # coerce these to DateTime. base.send(:coerce_field,date: ->(date) {DateTime.parse(date.to_s) unless date.nil?}) base.send(:coerce_field,modified: ->(modified) {DateTime.parse(modified.to_s) unless modified.nil?}) # Having coerced the fields, we can alias them (order is important - coerce first.) base.send(:alias_field, date: :created_at) base.send(:alias_field, modified: :updated_at) # Set up the hooks identified in other mixins. This method is defined in Rooftop::HookCalls base.send(:"setup_hooks!") end
included_classes()
click to toggle source
# File lib/rooftop/base.rb, line 52 def self.included_classes @included_classes end